Skip to content

Commit

Permalink
feat(projectSecrets): add CRUDL for project secrets (#40)
Browse files Browse the repository at this point in the history
Signed-off-by: Lukáš Janeček <[email protected]>
Co-authored-by: Lukáš Janeček <[email protected]>
  • Loading branch information
xjacka and Lukáš Janeček authored Jan 31, 2025
1 parent 6962b9f commit ecd16bd
Show file tree
Hide file tree
Showing 25 changed files with 962 additions and 96 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"@zilliz/milvus2-sdk-node": "^2.4.9",
"ajv": "^8.17.1",
"axios": "^1.7.7",
"bee-agent-framework": "0.0.57",
"bee-agent-framework": "0.0.58",
"bullmq": "^5.34.6",
"bullmq-otel": "^1.0.1",
"cache-manager": "^5.7.6",
Expand Down
33 changes: 16 additions & 17 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

66 changes: 66 additions & 0 deletions src/runs/dtos/run-submit-tool-inputs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/**
* Copyright 2024 IBM Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import { FromSchema, JSONSchema } from 'json-schema-to-ts';

import { runParamsSchema, runSchema } from './run.js';

import { eventSchema } from '@/streaming/dtos/event.js';

export const runSubmitToolInputsParamsSchema = runParamsSchema;
export type RunSubmitToolInputsParams = FromSchema<typeof runSubmitToolInputsParamsSchema>;

export const runSubmitToolInputsBodySchema = {
type: 'object',
required: ['tool_inputs'],
additionalProperties: false,
properties: {
tool_inputs: {
type: 'array',
items: {
type: 'object',
additionalProperties: false,
required: ['tool_call_id', 'inputs'],
properties: {
tool_call_id: { type: 'string' },
inputs: {
type: 'array',
items: {
type: 'object',
required: ['name', 'value'],
additionalProperties: false,
properties: {
name: { type: 'string' },
value: { type: 'string' }
}
}
}
}
}
},
stream: {
type: 'boolean',
nullable: true
}
}
} as const satisfies JSONSchema;
export type RunSubmitToolInputsBody = FromSchema<typeof runSubmitToolInputsBodySchema>;

export const runSubmitToolInputsResponseSchema = runSchema;
export type RunSubmitToolInputsResponse = FromSchema<typeof runSubmitToolInputsResponseSchema>;

export const runSubmitToolInputsStreamSchema = eventSchema;
export type RunSubmitToolInputsStream = FromSchema<typeof runSubmitToolInputsStreamSchema>;
17 changes: 17 additions & 0 deletions src/runs/dtos/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,23 @@ export const runSchema = {
}
}
},
{
required: ['type', 'submit_tool_inputs'],
properties: {
type: { const: 'submit_tool_inputs' },
submit_tool_inputs: {
type: 'object',
required: ['tool_calls', 'input_fields'],
properties: {
tool_calls: {
type: 'array',
items: toolCallSchema
},
input_fields: { type: 'array', items: { type: 'string' } }
}
}
}
},
{
required: ['type', 'submit_tool_approvals'],
properties: {
Expand Down
6 changes: 4 additions & 2 deletions src/runs/entities/requiredAction.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ import { Embeddable, Enum, Property } from '@mikro-orm/core';

import { RequiredToolApprove } from './requiredToolApprove.entity';
import { RequiredToolOutput } from './requiredToolOutput.entity';
import { RequiredToolInput } from './requiredToolInput.entity';

import { generatePrefixedObjectId } from '@/utils/id';

export enum RequiredActionType {
OUTPUT = 'output',
APPROVE = 'approve'
APPROVE = 'approve',
INPUT = 'input'
}

@Embeddable({ abstract: true, discriminatorColumn: 'type' })
Expand All @@ -35,4 +37,4 @@ export abstract class RequiredAction {
type!: RequiredActionType;
}

export type AnyRequiredAction = RequiredToolApprove | RequiredToolOutput;
export type AnyRequiredAction = RequiredToolApprove | RequiredToolInput | RequiredToolOutput;
45 changes: 45 additions & 0 deletions src/runs/entities/requiredToolInput.entity.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/**
* Copyright 2024 IBM Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import { Embeddable, Embedded, Property } from '@mikro-orm/core';

import { RequiredAction, RequiredActionType } from './requiredAction.entity';

import { CodeInterpreterCall } from '@/tools/entities/tool-calls/code-interpreter-call.entity';
import { FileSearchCall } from '@/tools/entities/tool-calls/file-search-call.entity';
import { FunctionCall } from '@/tools/entities/tool-calls/function-call.entity';
import { SystemCall } from '@/tools/entities/tool-calls/system-call.entity';
import { UserCall } from '@/tools/entities/tool-calls/user-call.entity';

@Embeddable({ discriminatorValue: RequiredActionType.INPUT })
export class RequiredToolInput extends RequiredAction {
type = RequiredActionType.INPUT;

// Union must be defined in alphabetical order, otherwise Mikro-ORM won't discovered the auto-created virtual polymorphic entity
@Embedded({ object: true })
toolCalls!: (CodeInterpreterCall | FileSearchCall | FunctionCall | SystemCall | UserCall)[];

@Property()
inputFields!: string[];

constructor({ toolCalls, inputFields }: RequiredToolInputInput) {
super();
this.toolCalls = toolCalls;
this.inputFields = inputFields;
}
}

export type RequiredToolInputInput = Pick<RequiredToolInput, 'toolCalls' | 'inputFields'>;
3 changes: 2 additions & 1 deletion src/runs/entities/run.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { RUN_EXPIRATION_MILLISECONDS } from '../execution/constants.js';
import { RequiredToolApprove } from './requiredToolApprove.entity.js';
import { RequiredToolOutput } from './requiredToolOutput.entity.js';
import { ToolApproval } from './toolApproval.entity.js';
import { RequiredToolInput } from './requiredToolInput.entity.js';

import { Assistant } from '@/assistants/assistant.entity.js';
import { Thread } from '@/threads/thread.entity.js';
Expand Down Expand Up @@ -75,7 +76,7 @@ export class Run extends PrincipalScopedEntity {

// Union must be defined in alphabetical order, otherwise Mikro-ORM won't discovered the auto-created virtual polymorphic entity
@Embedded({ object: true })
requiredAction?: RequiredToolApprove | RequiredToolOutput;
requiredAction?: RequiredToolApprove | RequiredToolInput | RequiredToolOutput;

@Embedded({ object: true })
toolApprovals?: ToolApproval[];
Expand Down
Loading

0 comments on commit ecd16bd

Please sign in to comment.