@zk-tech/ag-ui-core 0.0.1-alpha.7 → 0.0.1-alpha.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,17 @@
1
+ declare enum DesignProjectCtxNamespace {
2
+ Project = "project"
3
+ }
4
+ interface DesignProjectProjectCtx {
5
+ projectId: string;
6
+ /** 草稿版本号, 如果没有那么则传递 undefined */
7
+ workspaceHash: string | undefined;
8
+ }
9
+ declare enum AgentConfigCtxNamespace {
10
+ Config = "agent-config"
11
+ }
12
+ interface AgentConfigCtx {
13
+ /** 模型类型,对应 ModelType 枚举值 */
14
+ modelType: number;
15
+ }
16
+
17
+ export { AgentConfigCtxNamespace as A, DesignProjectCtxNamespace as D, type DesignProjectProjectCtx as a, type AgentConfigCtx as b };
@@ -0,0 +1,17 @@
1
+ declare enum DesignProjectCtxNamespace {
2
+ Project = "project"
3
+ }
4
+ interface DesignProjectProjectCtx {
5
+ projectId: string;
6
+ /** 草稿版本号, 如果没有那么则传递 undefined */
7
+ workspaceHash: string | undefined;
8
+ }
9
+ declare enum AgentConfigCtxNamespace {
10
+ Config = "agent-config"
11
+ }
12
+ interface AgentConfigCtx {
13
+ /** 模型类型,对应 ModelType 枚举值 */
14
+ modelType: number;
15
+ }
16
+
17
+ export { AgentConfigCtxNamespace as A, DesignProjectCtxNamespace as D, type DesignProjectProjectCtx as a, type AgentConfigCtx as b };
package/dist/index.cjs CHANGED
@@ -5,17 +5,10 @@ var DesignProjectCtxNamespace = /* @__PURE__ */ ((DesignProjectCtxNamespace2) =>
5
5
  DesignProjectCtxNamespace2["Project"] = "project";
6
6
  return DesignProjectCtxNamespace2;
7
7
  })(DesignProjectCtxNamespace || {});
8
- var AGENT_RESUME_CONTEXT_DESCRIPTION = "agent-resume";
9
- function createAgentResumeContext(interruptId, payload) {
10
- const contextValue = {
11
- interruptId,
12
- ...payload !== void 0 && { payload }
13
- };
14
- return {
15
- description: AGENT_RESUME_CONTEXT_DESCRIPTION,
16
- value: JSON.stringify(contextValue)
17
- };
18
- }
8
+ var AgentConfigCtxNamespace = /* @__PURE__ */ ((AgentConfigCtxNamespace2) => {
9
+ AgentConfigCtxNamespace2["Config"] = "agent-config";
10
+ return AgentConfigCtxNamespace2;
11
+ })(AgentConfigCtxNamespace || {});
19
12
 
20
13
  // src/utils/is-project-ctx.ts
21
14
  function isDesignProjectProjectCtx(value) {
@@ -54,11 +47,25 @@ function extractWorkspaceHashFromContext(context) {
54
47
  return void 0;
55
48
  }
56
49
 
57
- exports.AGENT_RESUME_CONTEXT_DESCRIPTION = AGENT_RESUME_CONTEXT_DESCRIPTION;
50
+ // src/utils/is-agent-config-ctx.ts
51
+ function isAgentConfigCtx(value) {
52
+ return typeof value === "object" && value !== null && "modelType" in value && typeof value.modelType === "number";
53
+ }
54
+
55
+ // src/utils/create-agent-config-context.ts
56
+ function createAgentConfigContext(ctx) {
57
+ return {
58
+ description: "agent-config" /* Config */,
59
+ value: JSON.stringify(ctx)
60
+ };
61
+ }
62
+
63
+ exports.AgentConfigCtxNamespace = AgentConfigCtxNamespace;
58
64
  exports.DesignProjectCtxNamespace = DesignProjectCtxNamespace;
59
- exports.createAgentResumeContext = createAgentResumeContext;
65
+ exports.createAgentConfigContext = createAgentConfigContext;
60
66
  exports.createProjectContext = createProjectContext;
61
67
  exports.extractWorkspaceHashFromContext = extractWorkspaceHashFromContext;
68
+ exports.isAgentConfigCtx = isAgentConfigCtx;
62
69
  exports.isDesignProjectProjectCtx = isDesignProjectProjectCtx;
63
70
  //# sourceMappingURL=index.cjs.map
64
71
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/protocol/context.ts","../src/utils/is-project-ctx.ts","../src/utils/create-project-context.ts","../src/utils/extract-workspace-hash-from-context.ts"],"names":["DesignProjectCtxNamespace"],"mappings":";;;AACO,IAAK,yBAAA,qBAAAA,0BAAAA,KAAL;AAEH,EAAAA,2BAAA,SAAA,CA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AAA,GAAW,KAAK,KAAA,CAAM,GAAA,CAAI,KAAK,CAAA,GAAI,GAAA,CAAI,KAAA;AAG3E,QAAA,IAAI,yBAAA,CAA0B,MAAM,CAAA,EAAG;AACrC,UAAA,OAAO,MAAA,CAAO,aAAA;AAAA,QAChB;AAAA,MACF,CAAA,CAAA,MAAQ;AAEN,QAAA;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,EAAA,OAAO,MAAA;AACT","file":"index.cjs","sourcesContent":["\nexport enum DesignProjectCtxNamespace {\n // 项目相关上下文\n Project = 'project',\n}\n\nexport interface DesignProjectProjectCtx {\n projectId: string;\n /** 草稿版本号, 如果没有那么则传递 undefined */\n workspaceHash: string | undefined;\n}\n\n/**\n * Agent Resume Context 协议\n * 用于 HITL (Human-in-the-Loop) 恢复机制\n */\n\n/**\n * Agent Resume Context 的值结构\n */\nexport interface AgentResumeContextValue {\n /** 中断 ID,必须匹配 RUN_FINISHED 事件中的 interrupt.id */\n interruptId: string;\n /** 用户响应数据,可以是 { action: 'continue' } 或其他格式 */\n payload?: unknown;\n}\n\n/**\n * Agent Resume Context 的描述符常量\n */\nexport const AGENT_RESUME_CONTEXT_DESCRIPTION = 'agent-resume';\n\n/**\n * 创建 Agent Resume Context\n * @param interruptId 中断 ID,必须匹配 RUN_FINISHED 事件中的 interrupt.id\n * @param payload 用户响应数据,可选\n * @returns 符合 AG-UI 协议的 Context 对象\n */\nexport function createAgentResumeContext(\n interruptId: string,\n payload?: unknown\n): { description: string; value: string } {\n const contextValue: AgentResumeContextValue = {\n interruptId,\n ...(payload !== undefined && { payload }),\n };\n\n return {\n description: AGENT_RESUME_CONTEXT_DESCRIPTION,\n value: JSON.stringify(contextValue),\n };\n}","/**\n * Type guard to check if an object matches DesignProjectProjectCtx\n */\nimport { type DesignProjectProjectCtx } from '../protocol';\n\nexport function isDesignProjectProjectCtx(value: unknown): value is DesignProjectProjectCtx {\n return (\n typeof value === 'object' &&\n value !== null &&\n 'projectId' in value &&\n typeof (value as Record<string, unknown>).projectId === 'string' &&\n (value as DesignProjectProjectCtx).projectId.length > 0\n );\n }\n ","/**\n * Create project context for AG-UI RunAgentInput\n */\nimport { type DesignProjectProjectCtx, DesignProjectCtxNamespace } from '../protocol';\nimport type { Context } from '@ag-ui/core';\n\n/**\n * Create a project context item for AG-UI RunAgentInput\n *\n * @param projectId - The project ID\n * @returns Context item with namespace 'project' and projectId in value\n */\nexport function createProjectContext(ctx: DesignProjectProjectCtx): Context {\n // const projectCtx: DesignProjectProjectCtx = { projectId, workspaceHash };\n return {\n description: DesignProjectCtxNamespace.Project,\n value: JSON.stringify(ctx),\n };\n}\n","/**\n * Extract workspaceHash from context array\n * Looks for context with namespace 'project' and extracts workspaceHash from value\n */\nimport { type DesignProjectProjectCtx, DesignProjectCtxNamespace } from '../protocol';\nimport { isDesignProjectProjectCtx } from './is-project-ctx';\n\n/**\n * Extract workspaceHash from context array\n * Looks for context with namespace 'project' and extracts workspaceHash from value\n *\n * @param context - Context array from RunAgentInput\n * @returns workspaceHash if found, undefined otherwise\n */\nexport function extractWorkspaceHashFromContext(\n context: Array<{ description?: string; value?: string }> | undefined\n): string | undefined {\n if (!context || !Array.isArray(context)) {\n return undefined;\n }\n\n // Look for context with namespace 'project'\n for (const ctx of context) {\n if (!ctx || typeof ctx !== 'object') {\n continue;\n }\n\n // Check if this is a project context (namespace = 'project')\n const namespace = ctx.description;\n if (namespace === DesignProjectCtxNamespace.Project && ctx.value) {\n try {\n // Parse value as JSON (AG-UI Context.value is a string)\n const parsed = typeof ctx.value === 'string' ? JSON.parse(ctx.value) : ctx.value;\n\n // Use type guard to validate and extract workspaceHash with proper typing\n if (isDesignProjectProjectCtx(parsed)) {\n return parsed.workspaceHash;\n }\n } catch {\n // Invalid JSON, skip this context\n continue;\n }\n }\n }\n\n return undefined;\n}"]}
1
+ {"version":3,"sources":["../src/protocol/context.ts","../src/utils/is-project-ctx.ts","../src/utils/create-project-context.ts","../src/utils/extract-workspace-hash-from-context.ts","../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KAAU,QAAA,GAAW,KAAK,KAAA,CAAM,GAAA,CAAI,KAAK,CAAA,GAAI,GAAA,CAAI,KAAA;AAG3E,QAAA,IAAI,yBAAA,CAA0B,MAAM,CAAA,EAAG;AACrC,UAAA,OAAO,MAAA,CAAO,aAAA;AAAA,QAChB;AAAA,MACF,CAAA,CAAA,MAAQ;AAEN,QAAA;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,EAAA,OAAO,MAAA;AACT;;;ACzCO,SAAS,iBAAiB,KAAA,EAAyC;AACxE,EAAA,OACE,OAAO,UAAU,QAAA,IACjB,KAAA,KAAU,QACV,WAAA,IAAe,KAAA,IACf,OAAQ,KAAA,CAAkC,SAAA,KAAc,QAAA;AAE5D;;;ACAO,SAAS,yBAAyB,GAAA,EAA8B;AACrE,EAAA,OAAO;AAAA,IACL,WAAA,EAAA,cAAA;AAAA,IACA,KAAA,EAAO,IAAA,CAAK,SAAA,CAAU,GAAG;AAAA,GAC3B;AACF","file":"index.cjs","sourcesContent":["\nexport enum DesignProjectCtxNamespace {\n // 项目相关上下文\n Project = 'project',\n}\n\nexport interface DesignProjectProjectCtx {\n projectId: string;\n /** 草稿版本号, 如果没有那么则传递 undefined */\n workspaceHash: string | undefined;\n}\n\nexport enum AgentConfigCtxNamespace {\n // Agent 配置相关上下文\n Config = 'agent-config',\n}\n\nexport interface AgentConfigCtx {\n /** 模型类型,对应 ModelType 枚举值 */\n modelType: number;\n}\n","/**\n * Type guard to check if an object matches DesignProjectProjectCtx\n */\nimport { type DesignProjectProjectCtx } from '../protocol';\n\nexport function isDesignProjectProjectCtx(value: unknown): value is DesignProjectProjectCtx {\n return (\n typeof value === 'object' &&\n value !== null &&\n 'projectId' in value &&\n typeof (value as Record<string, unknown>).projectId === 'string' &&\n (value as DesignProjectProjectCtx).projectId.length > 0\n );\n }\n ","/**\n * Create project context for AG-UI RunAgentInput\n */\nimport { type DesignProjectProjectCtx, DesignProjectCtxNamespace } from '../protocol';\nimport type { Context } from '@ag-ui/core';\n\n/**\n * Create a project context item for AG-UI RunAgentInput\n *\n * @param projectId - The project ID\n * @returns Context item with namespace 'project' and projectId in value\n */\nexport function createProjectContext(ctx: DesignProjectProjectCtx): Context {\n // const projectCtx: DesignProjectProjectCtx = { projectId, workspaceHash };\n return {\n description: DesignProjectCtxNamespace.Project,\n value: JSON.stringify(ctx),\n };\n}\n","/**\n * Extract workspaceHash from context array\n * Looks for context with namespace 'project' and extracts workspaceHash from value\n */\nimport { type DesignProjectProjectCtx, DesignProjectCtxNamespace } from '../protocol';\nimport { isDesignProjectProjectCtx } from './is-project-ctx';\n\n/**\n * Extract workspaceHash from context array\n * Looks for context with namespace 'project' and extracts workspaceHash from value\n *\n * @param context - Context array from RunAgentInput\n * @returns workspaceHash if found, undefined otherwise\n */\nexport function extractWorkspaceHashFromContext(\n context: Array<{ description?: string; value?: string }> | undefined\n): string | undefined {\n if (!context || !Array.isArray(context)) {\n return undefined;\n }\n\n // Look for context with namespace 'project'\n for (const ctx of context) {\n if (!ctx || typeof ctx !== 'object') {\n continue;\n }\n\n // Check if this is a project context (namespace = 'project')\n const namespace = ctx.description;\n if (namespace === DesignProjectCtxNamespace.Project && ctx.value) {\n try {\n // Parse value as JSON (AG-UI Context.value is a string)\n const parsed = typeof ctx.value === 'string' ? JSON.parse(ctx.value) : ctx.value;\n\n // Use type guard to validate and extract workspaceHash with proper typing\n if (isDesignProjectProjectCtx(parsed)) {\n return parsed.workspaceHash;\n }\n } catch {\n // Invalid JSON, skip this context\n continue;\n }\n }\n }\n\n return undefined;\n}","/**\n * Type guard to check if an object matches AgentConfigCtx\n */\nimport { type AgentConfigCtx } from '../protocol';\n\nexport function isAgentConfigCtx(value: unknown): value is AgentConfigCtx {\n return (\n typeof value === 'object' &&\n value !== null &&\n 'modelType' in value &&\n typeof (value as Record<string, unknown>).modelType === 'number'\n );\n}\n","/**\n * Create agent config context for AG-UI RunAgentInput\n */\nimport { type AgentConfigCtx, AgentConfigCtxNamespace } from '../protocol';\nimport type { Context } from '@ag-ui/core';\n\n/**\n * Create an agent config context item for AG-UI RunAgentInput\n *\n * @param ctx - The agent config context containing modelType\n * @returns Context item with namespace 'agent-config' and modelType in value\n */\nexport function createAgentConfigContext(ctx: AgentConfigCtx): Context {\n return {\n description: AgentConfigCtxNamespace.Config,\n value: JSON.stringify(ctx),\n };\n}\n"]}
package/dist/index.d.cts CHANGED
@@ -1,3 +1,4 @@
1
- export { AGENT_RESUME_CONTEXT_DESCRIPTION, AgentResumeContextValue, DesignProjectCtxNamespace, DesignProjectProjectCtx, createAgentResumeContext } from './protocol/index.cjs';
2
- export { createProjectContext, extractWorkspaceHashFromContext, isDesignProjectProjectCtx } from './utils/index.cjs';
1
+ export { b as AgentConfigCtx, A as AgentConfigCtxNamespace, D as DesignProjectCtxNamespace, a as DesignProjectProjectCtx } from './context-CRBz7KR8.cjs';
2
+ export { ResumeOption, RunAgentInput } from './protocol/index.cjs';
3
+ export { createAgentConfigContext, createProjectContext, extractWorkspaceHashFromContext, isAgentConfigCtx, isDesignProjectProjectCtx } from './utils/index.cjs';
3
4
  import '@ag-ui/core';
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
- export { AGENT_RESUME_CONTEXT_DESCRIPTION, AgentResumeContextValue, DesignProjectCtxNamespace, DesignProjectProjectCtx, createAgentResumeContext } from './protocol/index.js';
2
- export { createProjectContext, extractWorkspaceHashFromContext, isDesignProjectProjectCtx } from './utils/index.js';
1
+ export { b as AgentConfigCtx, A as AgentConfigCtxNamespace, D as DesignProjectCtxNamespace, a as DesignProjectProjectCtx } from './context-CRBz7KR8.js';
2
+ export { ResumeOption, RunAgentInput } from './protocol/index.js';
3
+ export { createAgentConfigContext, createProjectContext, extractWorkspaceHashFromContext, isAgentConfigCtx, isDesignProjectProjectCtx } from './utils/index.js';
3
4
  import '@ag-ui/core';
package/dist/index.js CHANGED
@@ -3,17 +3,10 @@ var DesignProjectCtxNamespace = /* @__PURE__ */ ((DesignProjectCtxNamespace2) =>
3
3
  DesignProjectCtxNamespace2["Project"] = "project";
4
4
  return DesignProjectCtxNamespace2;
5
5
  })(DesignProjectCtxNamespace || {});
6
- var AGENT_RESUME_CONTEXT_DESCRIPTION = "agent-resume";
7
- function createAgentResumeContext(interruptId, payload) {
8
- const contextValue = {
9
- interruptId,
10
- ...payload !== void 0 && { payload }
11
- };
12
- return {
13
- description: AGENT_RESUME_CONTEXT_DESCRIPTION,
14
- value: JSON.stringify(contextValue)
15
- };
16
- }
6
+ var AgentConfigCtxNamespace = /* @__PURE__ */ ((AgentConfigCtxNamespace2) => {
7
+ AgentConfigCtxNamespace2["Config"] = "agent-config";
8
+ return AgentConfigCtxNamespace2;
9
+ })(AgentConfigCtxNamespace || {});
17
10
 
18
11
  // src/utils/is-project-ctx.ts
19
12
  function isDesignProjectProjectCtx(value) {
@@ -52,6 +45,19 @@ function extractWorkspaceHashFromContext(context) {
52
45
  return void 0;
53
46
  }
54
47
 
55
- export { AGENT_RESUME_CONTEXT_DESCRIPTION, DesignProjectCtxNamespace, createAgentResumeContext, createProjectContext, extractWorkspaceHashFromContext, isDesignProjectProjectCtx };
48
+ // src/utils/is-agent-config-ctx.ts
49
+ function isAgentConfigCtx(value) {
50
+ return typeof value === "object" && value !== null && "modelType" in value && typeof value.modelType === "number";
51
+ }
52
+
53
+ // src/utils/create-agent-config-context.ts
54
+ function createAgentConfigContext(ctx) {
55
+ return {
56
+ description: "agent-config" /* Config */,
57
+ value: JSON.stringify(ctx)
58
+ };
59
+ }
60
+
61
+ export { AgentConfigCtxNamespace, DesignProjectCtxNamespace, createAgentConfigContext, createProjectContext, extractWorkspaceHashFromContext, isAgentConfigCtx, isDesignProjectProjectCtx };
56
62
  //# sourceMappingURL=index.js.map
57
63
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/protocol/context.ts","../src/utils/is-project-ctx.ts","../src/utils/create-project-context.ts","../src/utils/extract-workspace-hash-from-context.ts"],"names":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AAI,KAAA,EAAO;AAChE,MAAA,IAAI;AAEF,QAAA,MAAM,MAAA,GAAS,OAAO,GAAA,CAAI,KAAA,KAAU,QAAA,GAAW,KAAK,KAAA,CAAM,GAAA,CAAI,KAAK,CAAA,GAAI,GAAA,CAAI,KAAA;AAG3E,QAAA,IAAI,yBAAA,CAA0B,MAAM,CAAA,EAAG;AACrC,UAAA,OAAO,MAAA,CAAO,aAAA;AAAA,QAChB;AAAA,MACF,CAAA,CAAA,MAAQ;AAEN,QAAA;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,EAAA,OAAO,MAAA;AACT","file":"index.js","sourcesContent":["\nexport enum DesignProjectCtxNamespace {\n // 项目相关上下文\n Project = 'project',\n}\n\nexport interface DesignProjectProjectCtx {\n projectId: string;\n /** 草稿版本号, 如果没有那么则传递 undefined */\n workspaceHash: string | undefined;\n}\n\n/**\n * Agent Resume Context 协议\n * 用于 HITL (Human-in-the-Loop) 恢复机制\n */\n\n/**\n * Agent Resume Context 的值结构\n */\nexport interface AgentResumeContextValue {\n /** 中断 ID,必须匹配 RUN_FINISHED 事件中的 interrupt.id */\n interruptId: string;\n /** 用户响应数据,可以是 { action: 'continue' } 或其他格式 */\n payload?: unknown;\n}\n\n/**\n * Agent Resume Context 的描述符常量\n */\nexport const AGENT_RESUME_CONTEXT_DESCRIPTION = 'agent-resume';\n\n/**\n * 创建 Agent Resume Context\n * @param interruptId 中断 ID,必须匹配 RUN_FINISHED 事件中的 interrupt.id\n * @param payload 用户响应数据,可选\n * @returns 符合 AG-UI 协议的 Context 对象\n */\nexport function createAgentResumeContext(\n interruptId: string,\n payload?: unknown\n): { description: string; value: string } {\n const contextValue: AgentResumeContextValue = {\n interruptId,\n ...(payload !== undefined && { payload }),\n };\n\n return {\n description: AGENT_RESUME_CONTEXT_DESCRIPTION,\n value: JSON.stringify(contextValue),\n };\n}","/**\n * Type guard to check if an object matches DesignProjectProjectCtx\n */\nimport { type DesignProjectProjectCtx } from '../protocol';\n\nexport function isDesignProjectProjectCtx(value: unknown): value is DesignProjectProjectCtx {\n return (\n typeof value === 'object' &&\n value !== null &&\n 'projectId' in value &&\n typeof (value as Record<string, unknown>).projectId === 'string' &&\n (value as DesignProjectProjectCtx).projectId.length > 0\n );\n }\n ","/**\n * Create project context for AG-UI RunAgentInput\n */\nimport { type DesignProjectProjectCtx, DesignProjectCtxNamespace } from '../protocol';\nimport type { Context } from '@ag-ui/core';\n\n/**\n * Create a project context item for AG-UI RunAgentInput\n *\n * @param projectId - The project ID\n * @returns Context item with namespace 'project' and projectId in value\n */\nexport function createProjectContext(ctx: DesignProjectProjectCtx): Context {\n // const projectCtx: DesignProjectProjectCtx = { projectId, workspaceHash };\n return {\n description: DesignProjectCtxNamespace.Project,\n value: JSON.stringify(ctx),\n };\n}\n","/**\n * Extract workspaceHash from context array\n * Looks for context with namespace 'project' and extracts workspaceHash from value\n */\nimport { type DesignProjectProjectCtx, DesignProjectCtxNamespace } from '../protocol';\nimport { isDesignProjectProjectCtx } from './is-project-ctx';\n\n/**\n * Extract workspaceHash from context array\n * Looks for context with namespace 'project' and extracts workspaceHash from value\n *\n * @param context - Context array from RunAgentInput\n * @returns workspaceHash if found, undefined otherwise\n */\nexport function extractWorkspaceHashFromContext(\n context: Array<{ description?: string; value?: string }> | undefined\n): string | undefined {\n if (!context || !Array.isArray(context)) {\n return undefined;\n }\n\n // Look for context with namespace 'project'\n for (const ctx of context) {\n if (!ctx || typeof ctx !== 'object') {\n continue;\n }\n\n // Check if this is a project context (namespace = 'project')\n const namespace = ctx.description;\n if (namespace === DesignProjectCtxNamespace.Project && ctx.value) {\n try {\n // Parse value as JSON (AG-UI Context.value is a string)\n const parsed = typeof ctx.value === 'string' ? JSON.parse(ctx.value) : ctx.value;\n\n // Use type guard to validate and extract workspaceHash with proper typing\n if (isDesignProjectProjectCtx(parsed)) {\n return parsed.workspaceHash;\n }\n } catch {\n // Invalid JSON, skip this context\n continue;\n }\n }\n }\n\n return undefined;\n}"]}
1
+ {"version":3,"sources":["../src/protocol/context.ts","../src/utils/is-project-ctx.ts","../src/utils/create-project-context.ts","../src/utils/extract-workspace-hash-from-context.ts","../src/utils/is-agent-config-ctx.ts","../src/utils/create-agent-config-context.ts"],"names":["DesignProjectCtxNamespace","AgentConfigCtxNamespace"],"mappings":";AACO,IAAK,yBAAA,qBAAAA,0BAAAA,KAAL;AAEH,EAAAA,2BAAA,SAAA,CAAA,GAAU,SAAA;AAFF,EAAA,OAAAA,0BAAAA;AAAA,CAAA,EAAA,yBAAA,IAAA,EAAA;AAWL,IAAK,uBAAA,qBAAAC,wBAAAA,KAAL;AAEH,EAAAA,yBAAA,QAAA,CAAA,GAAS,cAAA;AAFD,EAAA,OAAAA,wBAAAA;AAAA,CAAA,EAAA,uBAAA,IAAA,EAAA;;;ACPL,SAAS,0BAA0B,KAAA,EAAkD;AACxF,EAAA,OACE,OAAO,KAAA,KAAU,QAAA,IACjB,KAAA,KAAU,IAAA,IACV,WAAA,IAAe,KAAA,IACf,OAAQ,KAAA,CAAkC,SAAA,KAAc,QAAA,IACvD,KAAA,CAAkC,UAAU,MAAA,GAAS,CAAA;AAE1D;;;ACDK,SAAS,qBAAqB,GAAA,EAAuC;AAE1E,EAAA,OAAO;AAAA,IACL,WAAA,EAAA,SAAA;AAAA,IACA,KAAA,EAAO,IAAA,CAAK,SAAA,CAAU,GAAG;AAAA,GAC3B;AACF;;;ACJO,SAAS,gCACd,OAAA,EACoB;AACpB,EAAA,IAAI,CAAC,OAAA,IAAW,CAAC,KAAA,CAAM,OAAA,CAAQ,OAAO,CAAA,EAAG;AACvC,IAAA,OAAO,MAAA;AAAA,EACT;AAGA,EAAA,KAAA,MAAW,OAAO,OAAA,EAAS;AACzB,IAAA,IAAI,CAAC,GAAA,IAAO,OAAO,GAAA,KAAQ,QAAA,EAAU;AACnC,MAAA;AAAA,IACF;AAGA,IAAA,MAAM,YAAY,GAAA,CAAI,WAAA;AACtB,IAAA,IAAI,SAAA,KAAA,SAAA,kBAAmD,IAAI,KAAA,EAAO;AAChE,MAAA,IAAI;AAEF,QAAA,MAAM,MAAA,GAAS,OAAO,GAAA,CAAI,KAAA,KAAU,QAAA,GAAW,KAAK,KAAA,CAAM,GAAA,CAAI,KAAK,CAAA,GAAI,GAAA,CAAI,KAAA;AAG3E,QAAA,IAAI,yBAAA,CAA0B,MAAM,CAAA,EAAG;AACrC,UAAA,OAAO,MAAA,CAAO,aAAA;AAAA,QAChB;AAAA,MACF,CAAA,CAAA,MAAQ;AAEN,QAAA;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,EAAA,OAAO,MAAA;AACT;;;ACzCO,SAAS,iBAAiB,KAAA,EAAyC;AACxE,EAAA,OACE,OAAO,UAAU,QAAA,IACjB,KAAA,KAAU,QACV,WAAA,IAAe,KAAA,IACf,OAAQ,KAAA,CAAkC,SAAA,KAAc,QAAA;AAE5D;;;ACAO,SAAS,yBAAyB,GAAA,EAA8B;AACrE,EAAA,OAAO;AAAA,IACL,WAAA,EAAA,cAAA;AAAA,IACA,KAAA,EAAO,IAAA,CAAK,SAAA,CAAU,GAAG;AAAA,GAC3B;AACF","file":"index.js","sourcesContent":["\nexport enum DesignProjectCtxNamespace {\n // 项目相关上下文\n Project = 'project',\n}\n\nexport interface DesignProjectProjectCtx {\n projectId: string;\n /** 草稿版本号, 如果没有那么则传递 undefined */\n workspaceHash: string | undefined;\n}\n\nexport enum AgentConfigCtxNamespace {\n // Agent 配置相关上下文\n Config = 'agent-config',\n}\n\nexport interface AgentConfigCtx {\n /** 模型类型,对应 ModelType 枚举值 */\n modelType: number;\n}\n","/**\n * Type guard to check if an object matches DesignProjectProjectCtx\n */\nimport { type DesignProjectProjectCtx } from '../protocol';\n\nexport function isDesignProjectProjectCtx(value: unknown): value is DesignProjectProjectCtx {\n return (\n typeof value === 'object' &&\n value !== null &&\n 'projectId' in value &&\n typeof (value as Record<string, unknown>).projectId === 'string' &&\n (value as DesignProjectProjectCtx).projectId.length > 0\n );\n }\n ","/**\n * Create project context for AG-UI RunAgentInput\n */\nimport { type DesignProjectProjectCtx, DesignProjectCtxNamespace } from '../protocol';\nimport type { Context } from '@ag-ui/core';\n\n/**\n * Create a project context item for AG-UI RunAgentInput\n *\n * @param projectId - The project ID\n * @returns Context item with namespace 'project' and projectId in value\n */\nexport function createProjectContext(ctx: DesignProjectProjectCtx): Context {\n // const projectCtx: DesignProjectProjectCtx = { projectId, workspaceHash };\n return {\n description: DesignProjectCtxNamespace.Project,\n value: JSON.stringify(ctx),\n };\n}\n","/**\n * Extract workspaceHash from context array\n * Looks for context with namespace 'project' and extracts workspaceHash from value\n */\nimport { type DesignProjectProjectCtx, DesignProjectCtxNamespace } from '../protocol';\nimport { isDesignProjectProjectCtx } from './is-project-ctx';\n\n/**\n * Extract workspaceHash from context array\n * Looks for context with namespace 'project' and extracts workspaceHash from value\n *\n * @param context - Context array from RunAgentInput\n * @returns workspaceHash if found, undefined otherwise\n */\nexport function extractWorkspaceHashFromContext(\n context: Array<{ description?: string; value?: string }> | undefined\n): string | undefined {\n if (!context || !Array.isArray(context)) {\n return undefined;\n }\n\n // Look for context with namespace 'project'\n for (const ctx of context) {\n if (!ctx || typeof ctx !== 'object') {\n continue;\n }\n\n // Check if this is a project context (namespace = 'project')\n const namespace = ctx.description;\n if (namespace === DesignProjectCtxNamespace.Project && ctx.value) {\n try {\n // Parse value as JSON (AG-UI Context.value is a string)\n const parsed = typeof ctx.value === 'string' ? JSON.parse(ctx.value) : ctx.value;\n\n // Use type guard to validate and extract workspaceHash with proper typing\n if (isDesignProjectProjectCtx(parsed)) {\n return parsed.workspaceHash;\n }\n } catch {\n // Invalid JSON, skip this context\n continue;\n }\n }\n }\n\n return undefined;\n}","/**\n * Type guard to check if an object matches AgentConfigCtx\n */\nimport { type AgentConfigCtx } from '../protocol';\n\nexport function isAgentConfigCtx(value: unknown): value is AgentConfigCtx {\n return (\n typeof value === 'object' &&\n value !== null &&\n 'modelType' in value &&\n typeof (value as Record<string, unknown>).modelType === 'number'\n );\n}\n","/**\n * Create agent config context for AG-UI RunAgentInput\n */\nimport { type AgentConfigCtx, AgentConfigCtxNamespace } from '../protocol';\nimport type { Context } from '@ag-ui/core';\n\n/**\n * Create an agent config context item for AG-UI RunAgentInput\n *\n * @param ctx - The agent config context containing modelType\n * @returns Context item with namespace 'agent-config' and modelType in value\n */\nexport function createAgentConfigContext(ctx: AgentConfigCtx): Context {\n return {\n description: AgentConfigCtxNamespace.Config,\n value: JSON.stringify(ctx),\n };\n}\n"]}
@@ -5,20 +5,12 @@ var DesignProjectCtxNamespace = /* @__PURE__ */ ((DesignProjectCtxNamespace2) =>
5
5
  DesignProjectCtxNamespace2["Project"] = "project";
6
6
  return DesignProjectCtxNamespace2;
7
7
  })(DesignProjectCtxNamespace || {});
8
- var AGENT_RESUME_CONTEXT_DESCRIPTION = "agent-resume";
9
- function createAgentResumeContext(interruptId, payload) {
10
- const contextValue = {
11
- interruptId,
12
- ...payload !== void 0 && { payload }
13
- };
14
- return {
15
- description: AGENT_RESUME_CONTEXT_DESCRIPTION,
16
- value: JSON.stringify(contextValue)
17
- };
18
- }
8
+ var AgentConfigCtxNamespace = /* @__PURE__ */ ((AgentConfigCtxNamespace2) => {
9
+ AgentConfigCtxNamespace2["Config"] = "agent-config";
10
+ return AgentConfigCtxNamespace2;
11
+ })(AgentConfigCtxNamespace || {});
19
12
 
20
- exports.AGENT_RESUME_CONTEXT_DESCRIPTION = AGENT_RESUME_CONTEXT_DESCRIPTION;
13
+ exports.AgentConfigCtxNamespace = AgentConfigCtxNamespace;
21
14
  exports.DesignProjectCtxNamespace = DesignProjectCtxNamespace;
22
- exports.createAgentResumeContext = createAgentResumeContext;
23
15
  //# sourceMappingURL=index.cjs.map
24
16
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/protocol/context.ts"],"names":["DesignProjectCtxNamespace"],"mappings":";;;AACO,IAAK,yBAAA,qBAAAA,0BAAAA,KAAL;AAEH,EAAAA,2BAAA,SAAA,CAAA,GAAU,SAAA;AAFF,EAAA,OAAAA,0BAAAA;AAAA,CAAA,EAAA,yBAAA,IAAA,EAAA;AA6BL,IAAM,gCAAA,GAAmC;AAQzC,SAAS,wBAAA,CACZ,aACA,OAAA,EACsC;AACtC,EAAA,MAAM,YAAA,GAAwC;AAAA,IAC1C,WAAA;AAAA,IACA,GAAI,OAAA,KAAY,MAAA,IAAa,EAAE,OAAA;AAAQ,GAC3C;AAEA,EAAA,OAAO;AAAA,IACH,WAAA,EAAa,gCAAA;AAAA,IACb,KAAA,EAAO,IAAA,CAAK,SAAA,CAAU,YAAY;AAAA,GACtC;AACJ","file":"index.cjs","sourcesContent":["\nexport enum DesignProjectCtxNamespace {\n // 项目相关上下文\n Project = 'project',\n}\n\nexport interface DesignProjectProjectCtx {\n projectId: string;\n /** 草稿版本号, 如果没有那么则传递 undefined */\n workspaceHash: string | undefined;\n}\n\n/**\n * Agent Resume Context 协议\n * 用于 HITL (Human-in-the-Loop) 恢复机制\n */\n\n/**\n * Agent Resume Context 的值结构\n */\nexport interface AgentResumeContextValue {\n /** 中断 ID,必须匹配 RUN_FINISHED 事件中的 interrupt.id */\n interruptId: string;\n /** 用户响应数据,可以是 { action: 'continue' } 或其他格式 */\n payload?: unknown;\n}\n\n/**\n * Agent Resume Context 的描述符常量\n */\nexport const AGENT_RESUME_CONTEXT_DESCRIPTION = 'agent-resume';\n\n/**\n * 创建 Agent Resume Context\n * @param interruptId 中断 ID,必须匹配 RUN_FINISHED 事件中的 interrupt.id\n * @param payload 用户响应数据,可选\n * @returns 符合 AG-UI 协议的 Context 对象\n */\nexport function createAgentResumeContext(\n interruptId: string,\n payload?: unknown\n): { description: string; value: string } {\n const contextValue: AgentResumeContextValue = {\n interruptId,\n ...(payload !== undefined && { payload }),\n };\n\n return {\n description: AGENT_RESUME_CONTEXT_DESCRIPTION,\n value: JSON.stringify(contextValue),\n };\n}"]}
1
+ {"version":3,"sources":["../../src/protocol/context.ts"],"names":["DesignProjectCtxNamespace","AgentConfigCtxNamespace"],"mappings":";;;AACO,IAAK,yBAAA,qBAAAA,0BAAAA,KAAL;AAEH,EAAAA,2BAAA,SAAA,CAAA,GAAU,SAAA;AAFF,EAAA,OAAAA,0BAAAA;AAAA,CAAA,EAAA,yBAAA,IAAA,EAAA;AAWL,IAAK,uBAAA,qBAAAC,wBAAAA,KAAL;AAEH,EAAAA,yBAAA,QAAA,CAAA,GAAS,cAAA;AAFD,EAAA,OAAAA,wBAAAA;AAAA,CAAA,EAAA,uBAAA,IAAA,EAAA","file":"index.cjs","sourcesContent":["\nexport enum DesignProjectCtxNamespace {\n // 项目相关上下文\n Project = 'project',\n}\n\nexport interface DesignProjectProjectCtx {\n projectId: string;\n /** 草稿版本号, 如果没有那么则传递 undefined */\n workspaceHash: string | undefined;\n}\n\nexport enum AgentConfigCtxNamespace {\n // Agent 配置相关上下文\n Config = 'agent-config',\n}\n\nexport interface AgentConfigCtx {\n /** 模型类型,对应 ModelType 枚举值 */\n modelType: number;\n}\n"]}
@@ -1,37 +1,36 @@
1
- declare enum DesignProjectCtxNamespace {
2
- Project = "project"
3
- }
4
- interface DesignProjectProjectCtx {
5
- projectId: string;
6
- /** 草稿版本号, 如果没有那么则传递 undefined */
7
- workspaceHash: string | undefined;
8
- }
1
+ export { b as AgentConfigCtx, A as AgentConfigCtxNamespace, D as DesignProjectCtxNamespace, a as DesignProjectProjectCtx } from '../context-CRBz7KR8.cjs';
2
+ import { RunAgentInput as RunAgentInput$1 } from '@ag-ui/core';
3
+
9
4
  /**
10
- * Agent Resume Context 协议
11
- * 用于 HITL (Human-in-the-Loop) 恢复机制
5
+ * RunAgentInput 类型重定义
6
+ * 直接使用 @ag-ui/core 的标准类型,保持协议一致性
12
7
  */
8
+
13
9
  /**
14
- * Agent Resume Context 的值结构
10
+ * Resume 选项类型(用于恢复中断的运行)
15
11
  */
16
- interface AgentResumeContextValue {
17
- /** 中断 ID,必须匹配 RUN_FINISHED 事件中的 interrupt.id */
18
- interruptId: string;
19
- /** 用户响应数据,可以是 { action: 'continue' } 或其他格式 */
20
- payload?: unknown;
12
+ interface ResumeOption {
13
+ /**
14
+ * 中断 ID(可选,如果提供了则回显)
15
+ * 来自 RUN_FINISHED 事件中的 interrupt.id
16
+ */
17
+ interruptId?: string;
18
+ /**
19
+ * 用户响应数据(任意 JSON)
20
+ * 可以包含 approvals、edits、files-as-refs 等
21
+ */
22
+ payload?: any;
21
23
  }
22
24
  /**
23
- * Agent Resume Context 的描述符常量
25
+ * RunAgentInput 类型重定义
26
+ * 基于 @ag-ui/core 的标准类型,扩展 resume 字段以支持中断恢复
24
27
  */
25
- declare const AGENT_RESUME_CONTEXT_DESCRIPTION = "agent-resume";
26
- /**
27
- * 创建 Agent Resume Context
28
- * @param interruptId 中断 ID,必须匹配 RUN_FINISHED 事件中的 interrupt.id
29
- * @param payload 用户响应数据,可选
30
- * @returns 符合 AG-UI 协议的 Context 对象
31
- */
32
- declare function createAgentResumeContext(interruptId: string, payload?: unknown): {
33
- description: string;
34
- value: string;
35
- };
28
+ interface RunAgentInput extends RunAgentInput$1 {
29
+ /**
30
+ * Resume 选项(用于恢复中断的运行)
31
+ * 当需要恢复一个被中断的 run 时,提供此字段
32
+ */
33
+ resume?: ResumeOption;
34
+ }
36
35
 
37
- export { AGENT_RESUME_CONTEXT_DESCRIPTION, type AgentResumeContextValue, DesignProjectCtxNamespace, type DesignProjectProjectCtx, createAgentResumeContext };
36
+ export type { ResumeOption, RunAgentInput };
@@ -1,37 +1,36 @@
1
- declare enum DesignProjectCtxNamespace {
2
- Project = "project"
3
- }
4
- interface DesignProjectProjectCtx {
5
- projectId: string;
6
- /** 草稿版本号, 如果没有那么则传递 undefined */
7
- workspaceHash: string | undefined;
8
- }
1
+ export { b as AgentConfigCtx, A as AgentConfigCtxNamespace, D as DesignProjectCtxNamespace, a as DesignProjectProjectCtx } from '../context-CRBz7KR8.js';
2
+ import { RunAgentInput as RunAgentInput$1 } from '@ag-ui/core';
3
+
9
4
  /**
10
- * Agent Resume Context 协议
11
- * 用于 HITL (Human-in-the-Loop) 恢复机制
5
+ * RunAgentInput 类型重定义
6
+ * 直接使用 @ag-ui/core 的标准类型,保持协议一致性
12
7
  */
8
+
13
9
  /**
14
- * Agent Resume Context 的值结构
10
+ * Resume 选项类型(用于恢复中断的运行)
15
11
  */
16
- interface AgentResumeContextValue {
17
- /** 中断 ID,必须匹配 RUN_FINISHED 事件中的 interrupt.id */
18
- interruptId: string;
19
- /** 用户响应数据,可以是 { action: 'continue' } 或其他格式 */
20
- payload?: unknown;
12
+ interface ResumeOption {
13
+ /**
14
+ * 中断 ID(可选,如果提供了则回显)
15
+ * 来自 RUN_FINISHED 事件中的 interrupt.id
16
+ */
17
+ interruptId?: string;
18
+ /**
19
+ * 用户响应数据(任意 JSON)
20
+ * 可以包含 approvals、edits、files-as-refs 等
21
+ */
22
+ payload?: any;
21
23
  }
22
24
  /**
23
- * Agent Resume Context 的描述符常量
25
+ * RunAgentInput 类型重定义
26
+ * 基于 @ag-ui/core 的标准类型,扩展 resume 字段以支持中断恢复
24
27
  */
25
- declare const AGENT_RESUME_CONTEXT_DESCRIPTION = "agent-resume";
26
- /**
27
- * 创建 Agent Resume Context
28
- * @param interruptId 中断 ID,必须匹配 RUN_FINISHED 事件中的 interrupt.id
29
- * @param payload 用户响应数据,可选
30
- * @returns 符合 AG-UI 协议的 Context 对象
31
- */
32
- declare function createAgentResumeContext(interruptId: string, payload?: unknown): {
33
- description: string;
34
- value: string;
35
- };
28
+ interface RunAgentInput extends RunAgentInput$1 {
29
+ /**
30
+ * Resume 选项(用于恢复中断的运行)
31
+ * 当需要恢复一个被中断的 run 时,提供此字段
32
+ */
33
+ resume?: ResumeOption;
34
+ }
36
35
 
37
- export { AGENT_RESUME_CONTEXT_DESCRIPTION, type AgentResumeContextValue, DesignProjectCtxNamespace, type DesignProjectProjectCtx, createAgentResumeContext };
36
+ export type { ResumeOption, RunAgentInput };
@@ -3,18 +3,11 @@ var DesignProjectCtxNamespace = /* @__PURE__ */ ((DesignProjectCtxNamespace2) =>
3
3
  DesignProjectCtxNamespace2["Project"] = "project";
4
4
  return DesignProjectCtxNamespace2;
5
5
  })(DesignProjectCtxNamespace || {});
6
- var AGENT_RESUME_CONTEXT_DESCRIPTION = "agent-resume";
7
- function createAgentResumeContext(interruptId, payload) {
8
- const contextValue = {
9
- interruptId,
10
- ...payload !== void 0 && { payload }
11
- };
12
- return {
13
- description: AGENT_RESUME_CONTEXT_DESCRIPTION,
14
- value: JSON.stringify(contextValue)
15
- };
16
- }
6
+ var AgentConfigCtxNamespace = /* @__PURE__ */ ((AgentConfigCtxNamespace2) => {
7
+ AgentConfigCtxNamespace2["Config"] = "agent-config";
8
+ return AgentConfigCtxNamespace2;
9
+ })(AgentConfigCtxNamespace || {});
17
10
 
18
- export { AGENT_RESUME_CONTEXT_DESCRIPTION, DesignProjectCtxNamespace, createAgentResumeContext };
11
+ export { AgentConfigCtxNamespace, DesignProjectCtxNamespace };
19
12
  //# sourceMappingURL=index.js.map
20
13
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/protocol/context.ts"],"names":["DesignProjectCtxNamespace"],"mappings":";AACO,IAAK,yBAAA,qBAAAA,0BAAAA,KAAL;AAEH,EAAAA,2BAAA,SAAA,CAAA,GAAU,SAAA;AAFF,EAAA,OAAAA,0BAAAA;AAAA,CAAA,EAAA,yBAAA,IAAA,EAAA;AA6BL,IAAM,gCAAA,GAAmC;AAQzC,SAAS,wBAAA,CACZ,aACA,OAAA,EACsC;AACtC,EAAA,MAAM,YAAA,GAAwC;AAAA,IAC1C,WAAA;AAAA,IACA,GAAI,OAAA,KAAY,MAAA,IAAa,EAAE,OAAA;AAAQ,GAC3C;AAEA,EAAA,OAAO;AAAA,IACH,WAAA,EAAa,gCAAA;AAAA,IACb,KAAA,EAAO,IAAA,CAAK,SAAA,CAAU,YAAY;AAAA,GACtC;AACJ","file":"index.js","sourcesContent":["\nexport enum DesignProjectCtxNamespace {\n // 项目相关上下文\n Project = 'project',\n}\n\nexport interface DesignProjectProjectCtx {\n projectId: string;\n /** 草稿版本号, 如果没有那么则传递 undefined */\n workspaceHash: string | undefined;\n}\n\n/**\n * Agent Resume Context 协议\n * 用于 HITL (Human-in-the-Loop) 恢复机制\n */\n\n/**\n * Agent Resume Context 的值结构\n */\nexport interface AgentResumeContextValue {\n /** 中断 ID,必须匹配 RUN_FINISHED 事件中的 interrupt.id */\n interruptId: string;\n /** 用户响应数据,可以是 { action: 'continue' } 或其他格式 */\n payload?: unknown;\n}\n\n/**\n * Agent Resume Context 的描述符常量\n */\nexport const AGENT_RESUME_CONTEXT_DESCRIPTION = 'agent-resume';\n\n/**\n * 创建 Agent Resume Context\n * @param interruptId 中断 ID,必须匹配 RUN_FINISHED 事件中的 interrupt.id\n * @param payload 用户响应数据,可选\n * @returns 符合 AG-UI 协议的 Context 对象\n */\nexport function createAgentResumeContext(\n interruptId: string,\n payload?: unknown\n): { description: string; value: string } {\n const contextValue: AgentResumeContextValue = {\n interruptId,\n ...(payload !== undefined && { payload }),\n };\n\n return {\n description: AGENT_RESUME_CONTEXT_DESCRIPTION,\n value: JSON.stringify(contextValue),\n };\n}"]}
1
+ {"version":3,"sources":["../../src/protocol/context.ts"],"names":["DesignProjectCtxNamespace","AgentConfigCtxNamespace"],"mappings":";AACO,IAAK,yBAAA,qBAAAA,0BAAAA,KAAL;AAEH,EAAAA,2BAAA,SAAA,CAAA,GAAU,SAAA;AAFF,EAAA,OAAAA,0BAAAA;AAAA,CAAA,EAAA,yBAAA,IAAA,EAAA;AAWL,IAAK,uBAAA,qBAAAC,wBAAAA,KAAL;AAEH,EAAAA,yBAAA,QAAA,CAAA,GAAS,cAAA;AAFD,EAAA,OAAAA,wBAAAA;AAAA,CAAA,EAAA,uBAAA,IAAA,EAAA","file":"index.js","sourcesContent":["\nexport enum DesignProjectCtxNamespace {\n // 项目相关上下文\n Project = 'project',\n}\n\nexport interface DesignProjectProjectCtx {\n projectId: string;\n /** 草稿版本号, 如果没有那么则传递 undefined */\n workspaceHash: string | undefined;\n}\n\nexport enum AgentConfigCtxNamespace {\n // Agent 配置相关上下文\n Config = 'agent-config',\n}\n\nexport interface AgentConfigCtx {\n /** 模型类型,对应 ModelType 枚举值 */\n modelType: number;\n}\n"]}
@@ -37,8 +37,23 @@ function extractWorkspaceHashFromContext(context) {
37
37
  return void 0;
38
38
  }
39
39
 
40
+ // src/utils/is-agent-config-ctx.ts
41
+ function isAgentConfigCtx(value) {
42
+ return typeof value === "object" && value !== null && "modelType" in value && typeof value.modelType === "number";
43
+ }
44
+
45
+ // src/utils/create-agent-config-context.ts
46
+ function createAgentConfigContext(ctx) {
47
+ return {
48
+ description: "agent-config" /* Config */,
49
+ value: JSON.stringify(ctx)
50
+ };
51
+ }
52
+
53
+ exports.createAgentConfigContext = createAgentConfigContext;
40
54
  exports.createProjectContext = createProjectContext;
41
55
  exports.extractWorkspaceHashFromContext = extractWorkspaceHashFromContext;
56
+ exports.isAgentConfigCtx = isAgentConfigCtx;
42
57
  exports.isDesignProjectProjectCtx = isDesignProjectProjectCtx;
43
58
  //# sourceMappingURL=index.cjs.map
44
59
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/is-project-ctx.ts","../../src/utils/create-project-context.ts","../../src/utils/extract-workspace-hash-from-context.ts"],"names":[],"mappings":";;;AAKO,SAAS,0BAA0B,KAAA,EAAkD;AACxF,EAAA,OACE,OAAO,KAAA,KAAU,QAAA,IACjB,KAAA,KAAU,IAAA,IACV,WAAA,IAAe,KAAA,IACf,OAAQ,KAAA,CAAkC,SAAA,KAAc,QAAA,IACvD,KAAA,CAAkC,UAAU,MAAA,GAAS,CAAA;AAE1D;;;ACDK,SAAS,qBAAqB,GAAA,EAAuC;AAE1E,EAAA,OAAO;AAAA,IACL,WAAA,EAAA,SAAA;AAAA,IACA,KAAA,EAAO,IAAA,CAAK,SAAA,CAAU,GAAG;AAAA,GAC3B;AACF;;;ACJO,SAAS,gCACd,OAAA,EACoB;AACpB,EAAA,IAAI,CAAC,OAAA,IAAW,CAAC,KAAA,CAAM,OAAA,CAAQ,OAAO,CAAA,EAAG;AACvC,IAAA,OAAO,MAAA;AAAA,EACT;AAGA,EAAA,KAAA,MAAW,OAAO,OAAA,EAAS;AACzB,IAAA,IAAI,CAAC,GAAA,IAAO,OAAO,GAAA,KAAQ,QAAA,EAAU;AACnC,MAAA;AAAA,IACF;AAGA,IAAA,MAAM,YAAY,GAAA,CAAI,WAAA;AACtB,IAAA,IAAI,SAAA,KAAA,SAAA,kBAAmD,IAAI,KAAA,EAAO;AAChE,MAAA,IAAI;AAEF,QAAA,MAAM,MAAA,GAAS,OAAO,GAAA,CAAI,KAAA,KAAU,QAAA,GAAW,KAAK,KAAA,CAAM,GAAA,CAAI,KAAK,CAAA,GAAI,GAAA,CAAI,KAAA;AAG3E,QAAA,IAAI,yBAAA,CAA0B,MAAM,CAAA,EAAG;AACrC,UAAA,OAAO,MAAA,CAAO,aAAA;AAAA,QAChB;AAAA,MACF,CAAA,CAAA,MAAQ;AAEN,QAAA;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,EAAA,OAAO,MAAA;AACT","file":"index.cjs","sourcesContent":["/**\n * Type guard to check if an object matches DesignProjectProjectCtx\n */\nimport { type DesignProjectProjectCtx } from '../protocol';\n\nexport function isDesignProjectProjectCtx(value: unknown): value is DesignProjectProjectCtx {\n return (\n typeof value === 'object' &&\n value !== null &&\n 'projectId' in value &&\n typeof (value as Record<string, unknown>).projectId === 'string' &&\n (value as DesignProjectProjectCtx).projectId.length > 0\n );\n }\n ","/**\n * Create project context for AG-UI RunAgentInput\n */\nimport { type DesignProjectProjectCtx, DesignProjectCtxNamespace } from '../protocol';\nimport type { Context } from '@ag-ui/core';\n\n/**\n * Create a project context item for AG-UI RunAgentInput\n *\n * @param projectId - The project ID\n * @returns Context item with namespace 'project' and projectId in value\n */\nexport function createProjectContext(ctx: DesignProjectProjectCtx): Context {\n // const projectCtx: DesignProjectProjectCtx = { projectId, workspaceHash };\n return {\n description: DesignProjectCtxNamespace.Project,\n value: JSON.stringify(ctx),\n };\n}\n","/**\n * Extract workspaceHash from context array\n * Looks for context with namespace 'project' and extracts workspaceHash from value\n */\nimport { type DesignProjectProjectCtx, DesignProjectCtxNamespace } from '../protocol';\nimport { isDesignProjectProjectCtx } from './is-project-ctx';\n\n/**\n * Extract workspaceHash from context array\n * Looks for context with namespace 'project' and extracts workspaceHash from value\n *\n * @param context - Context array from RunAgentInput\n * @returns workspaceHash if found, undefined otherwise\n */\nexport function extractWorkspaceHashFromContext(\n context: Array<{ description?: string; value?: string }> | undefined\n): string | undefined {\n if (!context || !Array.isArray(context)) {\n return undefined;\n }\n\n // Look for context with namespace 'project'\n for (const ctx of context) {\n if (!ctx || typeof ctx !== 'object') {\n continue;\n }\n\n // Check if this is a project context (namespace = 'project')\n const namespace = ctx.description;\n if (namespace === DesignProjectCtxNamespace.Project && ctx.value) {\n try {\n // Parse value as JSON (AG-UI Context.value is a string)\n const parsed = typeof ctx.value === 'string' ? JSON.parse(ctx.value) : ctx.value;\n\n // Use type guard to validate and extract workspaceHash with proper typing\n if (isDesignProjectProjectCtx(parsed)) {\n return parsed.workspaceHash;\n }\n } catch {\n // Invalid JSON, skip this context\n continue;\n }\n }\n }\n\n return undefined;\n}"]}
1
+ {"version":3,"sources":["../../src/utils/is-project-ctx.ts","../../src/utils/create-project-context.ts","../../src/utils/extract-workspace-hash-from-context.ts","../../src/utils/is-agent-config-ctx.ts","../../src/utils/create-agent-config-context.ts"],"names":[],"mappings":";;;AAKO,SAAS,0BAA0B,KAAA,EAAkD;AACxF,EAAA,OACE,OAAO,KAAA,KAAU,QAAA,IACjB,KAAA,KAAU,IAAA,IACV,WAAA,IAAe,KAAA,IACf,OAAQ,KAAA,CAAkC,SAAA,KAAc,QAAA,IACvD,KAAA,CAAkC,UAAU,MAAA,GAAS,CAAA;AAE1D;;;ACDK,SAAS,qBAAq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ard to check if an object matches DesignProjectProjectCtx\n */\nimport { type DesignProjectProjectCtx } from '../protocol';\n\nexport function isDesignProjectProjectCtx(value: unknown): value is DesignProjectProjectCtx {\n return (\n typeof value === 'object' &&\n value !== null &&\n 'projectId' in value &&\n typeof (value as Record<string, unknown>).projectId === 'string' &&\n (value as DesignProjectProjectCtx).projectId.length > 0\n );\n }\n ","/**\n * Create project context for AG-UI RunAgentInput\n */\nimport { type DesignProjectProjectCtx, DesignProjectCtxNamespace } from '../protocol';\nimport type { Context } from '@ag-ui/core';\n\n/**\n * Create a project context item for AG-UI RunAgentInput\n *\n * @param projectId - The project ID\n * @returns Context item with namespace 'project' and projectId in value\n */\nexport function createProjectContext(ctx: DesignProjectProjectCtx): Context {\n // const projectCtx: DesignProjectProjectCtx = { projectId, workspaceHash };\n return {\n description: DesignProjectCtxNamespace.Project,\n value: JSON.stringify(ctx),\n };\n}\n","/**\n * Extract workspaceHash from context array\n * Looks for context with namespace 'project' and extracts workspaceHash from value\n */\nimport { type DesignProjectProjectCtx, DesignProjectCtxNamespace } from '../protocol';\nimport { isDesignProjectProjectCtx } from './is-project-ctx';\n\n/**\n * Extract workspaceHash from context array\n * Looks for context with namespace 'project' and extracts workspaceHash from value\n *\n * @param context - Context array from RunAgentInput\n * @returns workspaceHash if found, undefined otherwise\n */\nexport function extractWorkspaceHashFromContext(\n context: Array<{ description?: string; value?: string }> | undefined\n): string | undefined {\n if (!context || !Array.isArray(context)) {\n return undefined;\n }\n\n // Look for context with namespace 'project'\n for (const ctx of context) {\n if (!ctx || typeof ctx !== 'object') {\n continue;\n }\n\n // Check if this is a project context (namespace = 'project')\n const namespace = ctx.description;\n if (namespace === DesignProjectCtxNamespace.Project && ctx.value) {\n try {\n // Parse value as JSON (AG-UI Context.value is a string)\n const parsed = typeof ctx.value === 'string' ? JSON.parse(ctx.value) : ctx.value;\n\n // Use type guard to validate and extract workspaceHash with proper typing\n if (isDesignProjectProjectCtx(parsed)) {\n return parsed.workspaceHash;\n }\n } catch {\n // Invalid JSON, skip this context\n continue;\n }\n }\n }\n\n return undefined;\n}","/**\n * Type guard to check if an object matches AgentConfigCtx\n */\nimport { type AgentConfigCtx } from '../protocol';\n\nexport function isAgentConfigCtx(value: unknown): value is AgentConfigCtx {\n return (\n typeof value === 'object' &&\n value !== null &&\n 'modelType' in value &&\n typeof (value as Record<string, unknown>).modelType === 'number'\n );\n}\n","/**\n * Create agent config context for AG-UI RunAgentInput\n */\nimport { type AgentConfigCtx, AgentConfigCtxNamespace } from '../protocol';\nimport type { Context } from '@ag-ui/core';\n\n/**\n * Create an agent config context item for AG-UI RunAgentInput\n *\n * @param ctx - The agent config context containing modelType\n * @returns Context item with namespace 'agent-config' and modelType in value\n */\nexport function createAgentConfigContext(ctx: AgentConfigCtx): Context {\n return {\n description: AgentConfigCtxNamespace.Config,\n value: JSON.stringify(ctx),\n };\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { DesignProjectProjectCtx } from '../protocol/index.cjs';
1
+ import { a as DesignProjectProjectCtx, b as AgentConfigCtx } from '../context-CRBz7KR8.cjs';
2
2
  import { Context } from '@ag-ui/core';
3
3
 
4
4
  /**
@@ -31,4 +31,22 @@ declare function extractWorkspaceHashFromContext(context: Array<{
31
31
  value?: string;
32
32
  }> | undefined): string | undefined;
33
33
 
34
- export { createProjectContext, extractWorkspaceHashFromContext, isDesignProjectProjectCtx };
34
+ /**
35
+ * Type guard to check if an object matches AgentConfigCtx
36
+ */
37
+
38
+ declare function isAgentConfigCtx(value: unknown): value is AgentConfigCtx;
39
+
40
+ /**
41
+ * Create agent config context for AG-UI RunAgentInput
42
+ */
43
+
44
+ /**
45
+ * Create an agent config context item for AG-UI RunAgentInput
46
+ *
47
+ * @param ctx - The agent config context containing modelType
48
+ * @returns Context item with namespace 'agent-config' and modelType in value
49
+ */
50
+ declare function createAgentConfigContext(ctx: AgentConfigCtx): Context;
51
+
52
+ export { createAgentConfigContext, createProjectContext, extractWorkspaceHashFromContext, isAgentConfigCtx, isDesignProjectProjectCtx };
@@ -1,4 +1,4 @@
1
- import { DesignProjectProjectCtx } from '../protocol/index.js';
1
+ import { a as DesignProjectProjectCtx, b as AgentConfigCtx } from '../context-CRBz7KR8.js';
2
2
  import { Context } from '@ag-ui/core';
3
3
 
4
4
  /**
@@ -31,4 +31,22 @@ declare function extractWorkspaceHashFromContext(context: Array<{
31
31
  value?: string;
32
32
  }> | undefined): string | undefined;
33
33
 
34
- export { createProjectContext, extractWorkspaceHashFromContext, isDesignProjectProjectCtx };
34
+ /**
35
+ * Type guard to check if an object matches AgentConfigCtx
36
+ */
37
+
38
+ declare function isAgentConfigCtx(value: unknown): value is AgentConfigCtx;
39
+
40
+ /**
41
+ * Create agent config context for AG-UI RunAgentInput
42
+ */
43
+
44
+ /**
45
+ * Create an agent config context item for AG-UI RunAgentInput
46
+ *
47
+ * @param ctx - The agent config context containing modelType
48
+ * @returns Context item with namespace 'agent-config' and modelType in value
49
+ */
50
+ declare function createAgentConfigContext(ctx: AgentConfigCtx): Context;
51
+
52
+ export { createAgentConfigContext, createProjectContext, extractWorkspaceHashFromContext, isAgentConfigCtx, isDesignProjectProjectCtx };
@@ -35,6 +35,19 @@ function extractWorkspaceHashFromContext(context) {
35
35
  return void 0;
36
36
  }
37
37
 
38
- export { createProjectContext, extractWorkspaceHashFromContext, isDesignProjectProjectCtx };
38
+ // src/utils/is-agent-config-ctx.ts
39
+ function isAgentConfigCtx(value) {
40
+ return typeof value === "object" && value !== null && "modelType" in value && typeof value.modelType === "number";
41
+ }
42
+
43
+ // src/utils/create-agent-config-context.ts
44
+ function createAgentConfigContext(ctx) {
45
+ return {
46
+ description: "agent-config" /* Config */,
47
+ value: JSON.stringify(ctx)
48
+ };
49
+ }
50
+
51
+ export { createAgentConfigContext, createProjectContext, extractWorkspaceHashFromContext, isAgentConfigCtx, isDesignProjectProjectCtx };
39
52
  //# sourceMappingURL=index.js.map
40
53
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/is-project-ctx.ts","../../src/utils/create-project-context.ts","../../src/utils/extract-workspace-hash-from-context.ts"],"names":[],"mappings":";AAKO,SAAS,0BAA0B,KAAA,EAAkD;AACxF,EAAA,OACE,OAAO,KAAA,KAAU,QAAA,IACjB,KAAA,KAAU,IAAA,IACV,WAAA,IAAe,KAAA,IACf,OAAQ,KAAA,CAAkC,SAAA,KAAc,QAAA,IACvD,KAAA,CAAkC,UAAU,MAAA,GAAS,CAAA;AAE1D;;;ACDK,SAAS,qBAAqB,GAAA,EAAuC;AAE1E,EAAA,OAAO;AAAA,IACL,WAAA,EAAA,SAAA;AAAA,IACA,KAAA,EAAO,IAAA,CAAK,SAAA,CAAU,GAAG;AAAA,GAC3B;AACF;;;ACJO,SAAS,gCACd,OAAA,EACoB;AACpB,EAAA,IAAI,CAAC,OAAA,IAAW,CAAC,KAAA,CAAM,OAAA,CAAQ,OAAO,CAAA,EAAG;AACvC,IAAA,OAAO,MAAA;AAAA,EACT;AAGA,EAAA,KAAA,MAAW,OAAO,OAAA,EAAS;AACzB,IAAA,IAAI,CAAC,GAAA,IAAO,OAAO,GAAA,KAAQ,QAAA,EAAU;AACnC,MAAA;AAAA,IACF;AAGA,IAAA,MAAM,YAAY,GAAA,CAAI,WAAA;AACtB,IAAA,IAAI,SAAA,KAAA,SAAA,kBAAmD,IAAI,KAAA,EAAO;AAChE,MAAA,IAAI;AAEF,QAAA,MAAM,MAAA,GAAS,OAAO,GAAA,CAAI,KAAA,KAAU,QAAA,GAAW,KAAK,KAAA,CAAM,GAAA,CAAI,KAAK,CAAA,GAAI,GAAA,CAAI,KAAA;AAG3E,QAAA,IAAI,yBAAA,CAA0B,MAAM,CAAA,EAAG;AACrC,UAAA,OAAO,MAAA,CAAO,aAAA;AAAA,QAChB;AAAA,MACF,CAAA,CAAA,MAAQ;AAEN,QAAA;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,EAAA,OAAO,MAAA;AACT","file":"index.js","sourcesContent":["/**\n * Type guard to check if an object matches DesignProjectProjectCtx\n */\nimport { type DesignProjectProjectCtx } from '../protocol';\n\nexport function isDesignProjectProjectCtx(value: unknown): value is DesignProjectProjectCtx {\n return (\n typeof value === 'object' &&\n value !== null &&\n 'projectId' in value &&\n typeof (value as Record<string, unknown>).projectId === 'string' &&\n (value as DesignProjectProjectCtx).projectId.length > 0\n );\n }\n ","/**\n * Create project context for AG-UI RunAgentInput\n */\nimport { type DesignProjectProjectCtx, DesignProjectCtxNamespace } from '../protocol';\nimport type { Context } from '@ag-ui/core';\n\n/**\n * Create a project context item for AG-UI RunAgentInput\n *\n * @param projectId - The project ID\n * @returns Context item with namespace 'project' and projectId in value\n */\nexport function createProjectContext(ctx: DesignProjectProjectCtx): Context {\n // const projectCtx: DesignProjectProjectCtx = { projectId, workspaceHash };\n return {\n description: DesignProjectCtxNamespace.Project,\n value: JSON.stringify(ctx),\n };\n}\n","/**\n * Extract workspaceHash from context array\n * Looks for context with namespace 'project' and extracts workspaceHash from value\n */\nimport { type DesignProjectProjectCtx, DesignProjectCtxNamespace } from '../protocol';\nimport { isDesignProjectProjectCtx } from './is-project-ctx';\n\n/**\n * Extract workspaceHash from context array\n * Looks for context with namespace 'project' and extracts workspaceHash from value\n *\n * @param context - Context array from RunAgentInput\n * @returns workspaceHash if found, undefined otherwise\n */\nexport function extractWorkspaceHashFromContext(\n context: Array<{ description?: string; value?: string }> | undefined\n): string | undefined {\n if (!context || !Array.isArray(context)) {\n return undefined;\n }\n\n // Look for context with namespace 'project'\n for (const ctx of context) {\n if (!ctx || typeof ctx !== 'object') {\n continue;\n }\n\n // Check if this is a project context (namespace = 'project')\n const namespace = ctx.description;\n if (namespace === DesignProjectCtxNamespace.Project && ctx.value) {\n try {\n // Parse value as JSON (AG-UI Context.value is a string)\n const parsed = typeof ctx.value === 'string' ? JSON.parse(ctx.value) : ctx.value;\n\n // Use type guard to validate and extract workspaceHash with proper typing\n if (isDesignProjectProjectCtx(parsed)) {\n return parsed.workspaceHash;\n }\n } catch {\n // Invalid JSON, skip this context\n continue;\n }\n }\n }\n\n return undefined;\n}"]}
1
+ {"version":3,"sources":["../../src/utils/is-project-ctx.ts","../../src/utils/create-project-context.ts","../../src/utils/extract-workspace-hash-from-context.ts","../../src/utils/is-agent-config-ctx.ts","../../src/utils/create-agent-config-context.ts"],"names":[],"mappings":";AAKO,SAAS,0BAA0B,KAAA,EAAkD;AACxF,EAAA,OACE,OAAO,KAAA,KAAU,QAAA,IACjB,KAAA,KAAU,IAAA,IACV,WAAA,IAAe,KAAA,IACf,OAAQ,KAAA,CAAkC,SAAA,KAAc,QAAA,IACvD,KAAA,CAAkC,UAAU,MAAA,GAAS,CAAA;AAE1D;;;ACDK,SAAS,qBAAqB,GAAA,EAAuC;AAE1E,EAAA,OAAO;AAAA,IACL,WAAA,EAAA,SAAA;AAAA,IACA,KAAA,EAAO,IAAA,CAAK,SAAA,CAAU,GAAG;AAAA,GAC3B;AACF;;;ACJO,SAAS,gCACd,OAAA,EACoB;AACpB,EAAA,IAAI,CAAC,OAAA,IAAW,CAAC,KAAA,CAAM,OAAA,CAAQ,OAAO,CAAA,EAAG;AACvC,IAAA,OAAO,MAAA;AAAA,EACT;AAGA,EAAA,KAAA,MAAW,OAAO,OAAA,EAAS;AACzB,IAAA,IAAI,CAAC,GAAA,IAAO,OAAO,GAAA,KAAQ,QAAA,EAAU;AACnC,MAAA;AAAA,IACF;AAGA,IAAA,MAAM,YAAY,GAAA,CAAI,WAAA;AACtB,IAAA,IAAI,SAAA,KAAA,SAAA,kBAAmD,IAAI,KAAA,EAAO;AAChE,MAAA,IAAI;AAEF,QAAA,MAAM,MAAA,GAAS,OAAO,GAAA,CAAI,KAAA,KAAU,QAAA,GAAW,KAAK,KAAA,CAAM,GAAA,CAAI,KAAK,CAAA,GAAI,GAAA,CAAI,KAAA;AAG3E,QAAA,IAAI,yBAAA,CAA0B,MAAM,CAAA,EAAG;AACrC,UAAA,OAAO,MAAA,CAAO,aAAA;AAAA,QAChB;AAAA,MACF,CAAA,CAAA,MAAQ;AAEN,QAAA;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,EAAA,OAAO,MAAA;AACT;;;ACzCO,SAAS,iBAAiB,KAAA,EAAyC;AACxE,EAAA,OACE,OAAO,UAAU,QAAA,IACjB,KAAA,KAAU,QACV,WAAA,IAAe,KAAA,IACf,OAAQ,KAAA,CAAkC,SAAA,KAAc,QAAA;AAE5D;;;ACAO,SAAS,yBAAyB,GAAA,EAA8B;AACrE,EAAA,OAAO;AAAA,IACL,WAAA,EAAA,cAAA;AAAA,IACA,KAAA,EAAO,IAAA,CAAK,SAAA,CAAU,GAAG;AAAA,GAC3B;AACF","file":"index.js","sourcesContent":["/**\n * Type guard to check if an object matches DesignProjectProjectCtx\n */\nimport { type DesignProjectProjectCtx } from '../protocol';\n\nexport function isDesignProjectProjectCtx(value: unknown): value is DesignProjectProjectCtx {\n return (\n typeof value === 'object' &&\n value !== null &&\n 'projectId' in value &&\n typeof (value as Record<string, unknown>).projectId === 'string' &&\n (value as DesignProjectProjectCtx).projectId.length > 0\n );\n }\n ","/**\n * Create project context for AG-UI RunAgentInput\n */\nimport { type DesignProjectProjectCtx, DesignProjectCtxNamespace } from '../protocol';\nimport type { Context } from '@ag-ui/core';\n\n/**\n * Create a project context item for AG-UI RunAgentInput\n *\n * @param projectId - The project ID\n * @returns Context item with namespace 'project' and projectId in value\n */\nexport function createProjectContext(ctx: DesignProjectProjectCtx): Context {\n // const projectCtx: DesignProjectProjectCtx = { projectId, workspaceHash };\n return {\n description: DesignProjectCtxNamespace.Project,\n value: JSON.stringify(ctx),\n };\n}\n","/**\n * Extract workspaceHash from context array\n * Looks for context with namespace 'project' and extracts workspaceHash from value\n */\nimport { type DesignProjectProjectCtx, DesignProjectCtxNamespace } from '../protocol';\nimport { isDesignProjectProjectCtx } from './is-project-ctx';\n\n/**\n * Extract workspaceHash from context array\n * Looks for context with namespace 'project' and extracts workspaceHash from value\n *\n * @param context - Context array from RunAgentInput\n * @returns workspaceHash if found, undefined otherwise\n */\nexport function extractWorkspaceHashFromContext(\n context: Array<{ description?: string; value?: string }> | undefined\n): string | undefined {\n if (!context || !Array.isArray(context)) {\n return undefined;\n }\n\n // Look for context with namespace 'project'\n for (const ctx of context) {\n if (!ctx || typeof ctx !== 'object') {\n continue;\n }\n\n // Check if this is a project context (namespace = 'project')\n const namespace = ctx.description;\n if (namespace === DesignProjectCtxNamespace.Project && ctx.value) {\n try {\n // Parse value as JSON (AG-UI Context.value is a string)\n const parsed = typeof ctx.value === 'string' ? JSON.parse(ctx.value) : ctx.value;\n\n // Use type guard to validate and extract workspaceHash with proper typing\n if (isDesignProjectProjectCtx(parsed)) {\n return parsed.workspaceHash;\n }\n } catch {\n // Invalid JSON, skip this context\n continue;\n }\n }\n }\n\n return undefined;\n}","/**\n * Type guard to check if an object matches AgentConfigCtx\n */\nimport { type AgentConfigCtx } from '../protocol';\n\nexport function isAgentConfigCtx(value: unknown): value is AgentConfigCtx {\n return (\n typeof value === 'object' &&\n value !== null &&\n 'modelType' in value &&\n typeof (value as Record<string, unknown>).modelType === 'number'\n );\n}\n","/**\n * Create agent config context for AG-UI RunAgentInput\n */\nimport { type AgentConfigCtx, AgentConfigCtxNamespace } from '../protocol';\nimport type { Context } from '@ag-ui/core';\n\n/**\n * Create an agent config context item for AG-UI RunAgentInput\n *\n * @param ctx - The agent config context containing modelType\n * @returns Context item with namespace 'agent-config' and modelType in value\n */\nexport function createAgentConfigContext(ctx: AgentConfigCtx): Context {\n return {\n description: AgentConfigCtxNamespace.Config,\n value: JSON.stringify(ctx),\n };\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zk-tech/ag-ui-core",
3
- "version": "0.0.1-alpha.7",
3
+ "version": "0.0.1-alpha.9",
4
4
  "description": "Extends from AG-UI core with more strict types",
5
5
  "license": "MIT",
6
6
  "author": "ZK Tech",