mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 08:11:26 +00:00
feat(gateway): add agents.create/update/delete methods (#11045)
* feat(gateway): add agents.create/update/delete methods * fix(lint): preserve memory-lancedb load error cause * feat(gateway): trash agent files on agents.delete * chore(protocol): regenerate Swift gateway models * fix(gateway): stabilize agents.create dirs and agentDir * feat(gateway): support avatar in agents.create * fix: prep agents.create/update/delete handlers (#11045) (thanks @advaitpaliwal) - Reuse movePathToTrash from browser/trash.ts (has ~/.Trash fallback on non-macOS) - Fix partial-failure: workspace setup now runs before config write - Always write Name to IDENTITY.md regardless of emoji/avatar - Add unit tests for agents.create, agents.update, agents.delete - Add CHANGELOG entry --------- Co-authored-by: Tyler Yust <TYTYYUST@YAHOO.COM>
This commit is contained in:
@@ -12,6 +12,18 @@ import {
|
||||
AgentSummarySchema,
|
||||
type AgentsFileEntry,
|
||||
AgentsFileEntrySchema,
|
||||
type AgentsCreateParams,
|
||||
AgentsCreateParamsSchema,
|
||||
type AgentsCreateResult,
|
||||
AgentsCreateResultSchema,
|
||||
type AgentsUpdateParams,
|
||||
AgentsUpdateParamsSchema,
|
||||
type AgentsUpdateResult,
|
||||
AgentsUpdateResultSchema,
|
||||
type AgentsDeleteParams,
|
||||
AgentsDeleteParamsSchema,
|
||||
type AgentsDeleteResult,
|
||||
AgentsDeleteResultSchema,
|
||||
type AgentsFilesGetParams,
|
||||
AgentsFilesGetParamsSchema,
|
||||
type AgentsFilesGetResult,
|
||||
@@ -226,6 +238,9 @@ export const validateAgentIdentityParams =
|
||||
export const validateAgentWaitParams = ajv.compile<AgentWaitParams>(AgentWaitParamsSchema);
|
||||
export const validateWakeParams = ajv.compile<WakeParams>(WakeParamsSchema);
|
||||
export const validateAgentsListParams = ajv.compile<AgentsListParams>(AgentsListParamsSchema);
|
||||
export const validateAgentsCreateParams = ajv.compile<AgentsCreateParams>(AgentsCreateParamsSchema);
|
||||
export const validateAgentsUpdateParams = ajv.compile<AgentsUpdateParams>(AgentsUpdateParamsSchema);
|
||||
export const validateAgentsDeleteParams = ajv.compile<AgentsDeleteParams>(AgentsDeleteParamsSchema);
|
||||
export const validateAgentsFilesListParams = ajv.compile<AgentsFilesListParams>(
|
||||
AgentsFilesListParamsSchema,
|
||||
);
|
||||
@@ -438,6 +453,12 @@ export {
|
||||
WebLoginWaitParamsSchema,
|
||||
AgentSummarySchema,
|
||||
AgentsFileEntrySchema,
|
||||
AgentsCreateParamsSchema,
|
||||
AgentsCreateResultSchema,
|
||||
AgentsUpdateParamsSchema,
|
||||
AgentsUpdateResultSchema,
|
||||
AgentsDeleteParamsSchema,
|
||||
AgentsDeleteResultSchema,
|
||||
AgentsFilesListParamsSchema,
|
||||
AgentsFilesListResultSchema,
|
||||
AgentsFilesGetParamsSchema,
|
||||
@@ -519,6 +540,12 @@ export type {
|
||||
WebLoginWaitParams,
|
||||
AgentSummary,
|
||||
AgentsFileEntry,
|
||||
AgentsCreateParams,
|
||||
AgentsCreateResult,
|
||||
AgentsUpdateParams,
|
||||
AgentsUpdateResult,
|
||||
AgentsDeleteParams,
|
||||
AgentsDeleteResult,
|
||||
AgentsFilesListParams,
|
||||
AgentsFilesListResult,
|
||||
AgentsFilesGetParams,
|
||||
|
||||
@@ -44,6 +44,62 @@ export const AgentsListResultSchema = Type.Object(
|
||||
{ additionalProperties: false },
|
||||
);
|
||||
|
||||
export const AgentsCreateParamsSchema = Type.Object(
|
||||
{
|
||||
name: NonEmptyString,
|
||||
workspace: NonEmptyString,
|
||||
emoji: Type.Optional(Type.String()),
|
||||
avatar: Type.Optional(Type.String()),
|
||||
},
|
||||
{ additionalProperties: false },
|
||||
);
|
||||
|
||||
export const AgentsCreateResultSchema = Type.Object(
|
||||
{
|
||||
ok: Type.Literal(true),
|
||||
agentId: NonEmptyString,
|
||||
name: NonEmptyString,
|
||||
workspace: NonEmptyString,
|
||||
},
|
||||
{ additionalProperties: false },
|
||||
);
|
||||
|
||||
export const AgentsUpdateParamsSchema = Type.Object(
|
||||
{
|
||||
agentId: NonEmptyString,
|
||||
name: Type.Optional(NonEmptyString),
|
||||
workspace: Type.Optional(NonEmptyString),
|
||||
model: Type.Optional(NonEmptyString),
|
||||
avatar: Type.Optional(Type.String()),
|
||||
},
|
||||
{ additionalProperties: false },
|
||||
);
|
||||
|
||||
export const AgentsUpdateResultSchema = Type.Object(
|
||||
{
|
||||
ok: Type.Literal(true),
|
||||
agentId: NonEmptyString,
|
||||
},
|
||||
{ additionalProperties: false },
|
||||
);
|
||||
|
||||
export const AgentsDeleteParamsSchema = Type.Object(
|
||||
{
|
||||
agentId: NonEmptyString,
|
||||
deleteFiles: Type.Optional(Type.Boolean()),
|
||||
},
|
||||
{ additionalProperties: false },
|
||||
);
|
||||
|
||||
export const AgentsDeleteResultSchema = Type.Object(
|
||||
{
|
||||
ok: Type.Literal(true),
|
||||
agentId: NonEmptyString,
|
||||
removedBindings: Type.Integer({ minimum: 0 }),
|
||||
},
|
||||
{ additionalProperties: false },
|
||||
);
|
||||
|
||||
export const AgentsFileEntrySchema = Type.Object(
|
||||
{
|
||||
name: NonEmptyString,
|
||||
|
||||
@@ -11,6 +11,10 @@ import {
|
||||
} from "./agent.js";
|
||||
import {
|
||||
AgentSummarySchema,
|
||||
AgentsCreateParamsSchema,
|
||||
AgentsCreateResultSchema,
|
||||
AgentsDeleteParamsSchema,
|
||||
AgentsDeleteResultSchema,
|
||||
AgentsFileEntrySchema,
|
||||
AgentsFilesGetParamsSchema,
|
||||
AgentsFilesGetResultSchema,
|
||||
@@ -20,6 +24,8 @@ import {
|
||||
AgentsFilesSetResultSchema,
|
||||
AgentsListParamsSchema,
|
||||
AgentsListResultSchema,
|
||||
AgentsUpdateParamsSchema,
|
||||
AgentsUpdateResultSchema,
|
||||
ModelChoiceSchema,
|
||||
ModelsListParamsSchema,
|
||||
ModelsListResultSchema,
|
||||
@@ -191,6 +197,12 @@ export const ProtocolSchemas: Record<string, TSchema> = {
|
||||
WebLoginStartParams: WebLoginStartParamsSchema,
|
||||
WebLoginWaitParams: WebLoginWaitParamsSchema,
|
||||
AgentSummary: AgentSummarySchema,
|
||||
AgentsCreateParams: AgentsCreateParamsSchema,
|
||||
AgentsCreateResult: AgentsCreateResultSchema,
|
||||
AgentsUpdateParams: AgentsUpdateParamsSchema,
|
||||
AgentsUpdateResult: AgentsUpdateResultSchema,
|
||||
AgentsDeleteParams: AgentsDeleteParamsSchema,
|
||||
AgentsDeleteResult: AgentsDeleteResultSchema,
|
||||
AgentsFileEntry: AgentsFileEntrySchema,
|
||||
AgentsFilesListParams: AgentsFilesListParamsSchema,
|
||||
AgentsFilesListResult: AgentsFilesListResultSchema,
|
||||
|
||||
@@ -10,6 +10,10 @@ import type {
|
||||
import type {
|
||||
AgentSummarySchema,
|
||||
AgentsFileEntrySchema,
|
||||
AgentsCreateParamsSchema,
|
||||
AgentsCreateResultSchema,
|
||||
AgentsDeleteParamsSchema,
|
||||
AgentsDeleteResultSchema,
|
||||
AgentsFilesGetParamsSchema,
|
||||
AgentsFilesGetResultSchema,
|
||||
AgentsFilesListParamsSchema,
|
||||
@@ -18,6 +22,8 @@ import type {
|
||||
AgentsFilesSetResultSchema,
|
||||
AgentsListParamsSchema,
|
||||
AgentsListResultSchema,
|
||||
AgentsUpdateParamsSchema,
|
||||
AgentsUpdateResultSchema,
|
||||
ModelChoiceSchema,
|
||||
ModelsListParamsSchema,
|
||||
ModelsListResultSchema,
|
||||
@@ -181,6 +187,12 @@ export type WebLoginStartParams = Static<typeof WebLoginStartParamsSchema>;
|
||||
export type WebLoginWaitParams = Static<typeof WebLoginWaitParamsSchema>;
|
||||
export type AgentSummary = Static<typeof AgentSummarySchema>;
|
||||
export type AgentsFileEntry = Static<typeof AgentsFileEntrySchema>;
|
||||
export type AgentsCreateParams = Static<typeof AgentsCreateParamsSchema>;
|
||||
export type AgentsCreateResult = Static<typeof AgentsCreateResultSchema>;
|
||||
export type AgentsUpdateParams = Static<typeof AgentsUpdateParamsSchema>;
|
||||
export type AgentsUpdateResult = Static<typeof AgentsUpdateResultSchema>;
|
||||
export type AgentsDeleteParams = Static<typeof AgentsDeleteParamsSchema>;
|
||||
export type AgentsDeleteResult = Static<typeof AgentsDeleteResultSchema>;
|
||||
export type AgentsFilesListParams = Static<typeof AgentsFilesListParamsSchema>;
|
||||
export type AgentsFilesListResult = Static<typeof AgentsFilesListResultSchema>;
|
||||
export type AgentsFilesGetParams = Static<typeof AgentsFilesGetParamsSchema>;
|
||||
|
||||
Reference in New Issue
Block a user