@crewx/sdk 0.9.0-rc.120 → 0.9.0-rc.121

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,14 @@
1
+ import type { UiActionConfirmation } from '../ui-instance/types.js';
2
+ export type McpAppAgentAccess = 'allowed' | 'approval_required' | 'denied';
3
+ export interface McpAppAgentAccessAction {
4
+ readonly actionId: string;
5
+ readonly confirmation: UiActionConfirmation | undefined;
6
+ readonly backend?: {
7
+ readonly type: 'core';
8
+ readonly handler: string;
9
+ } | {
10
+ readonly type: 'skill';
11
+ readonly command?: readonly string[];
12
+ };
13
+ }
14
+ export declare function resolveAgentAccess(action: McpAppAgentAccessAction, modelActions?: readonly string[]): McpAppAgentAccess;
@@ -1,5 +1,6 @@
1
1
  import type { McpAppStateDescriptor } from './types.js';
2
+ import type { McpAppModelContext } from './model-context.js';
2
3
  export interface McpAppsContext {
3
4
  readonly rendered: string;
4
5
  }
5
- export declare function buildMcpAppsContext(descriptors: readonly McpAppStateDescriptor[] | undefined): McpAppsContext | undefined;
6
+ export declare function buildMcpAppsContext(descriptors: readonly McpAppStateDescriptor[] | undefined, modelContext?: McpAppModelContext): McpAppsContext | undefined;
@@ -10,11 +10,15 @@ export type { CrewxAppBuiltinCatalog, CrewxAppCapability, CrewxAppCatalogOptions
10
10
  export { MCP_APP_PROJECTION_MAX_BYTES, buildMcpAppStateDescriptor, buildMcpAppStateProjections, buildTerminalMcpAppStateDescriptor, buildTerminalMcpAppStateProjections, createMcpAppToolResult, serializeMcpAppStateJson, serializeMcpAppStateXml, } from './projection.js';
11
11
  export { buildMcpAppsContext } from './apps-context.js';
12
12
  export type { McpAppsContext } from './apps-context.js';
13
+ export { MCP_APP_MODEL_CONTEXT_MAX_ARRAY_LENGTH, MCP_APP_MODEL_CONTEXT_MAX_BYTES, MCP_APP_MODEL_CONTEXT_MAX_DEPTH, MCP_APP_MODEL_CONTEXT_MAX_STRING_LENGTH, sanitizeMcpAppModelContext, serializeMcpAppModelContextXml, } from './model-context.js';
14
+ export type { McpAppModelContext, McpAppModelContextInput } from './model-context.js';
15
+ export { resolveAgentAccess } from './agent-access.js';
16
+ export type { McpAppAgentAccess, McpAppAgentAccessAction } from './agent-access.js';
13
17
  export { buildStateSetHandler, createStateSetHandler, } from './state-set.js';
14
18
  export type { StateSetHandlerBuildInput } from './state-set.js';
15
19
  export { SKILL_BACKEND_DEFAULT_TIMEOUT_MS, SKILL_BACKEND_MAX_INPUT_BYTES, SKILL_BACKEND_MAX_OUTPUT_BYTES, SKILL_BACKEND_SCHEMA_VERSION, buildSkillBackendHandler, } from './skill-backend.js';
16
20
  export type { SkillBackendExecutionPort, SkillBackendExecutionRequest, SkillBackendExecutionResponse, SkillBackendHandlerBuildInput, SkillBackendInfrastructureErrorCode, SkillBackendPayload, } from './skill-backend.js';
17
21
  export { MCP_APP_HOST_TOOL_ALLOWLIST, MCP_APP_LOCAL_RESOURCE_MIME_TYPE, MCP_APP_RESOURCE_MIME_TYPE, MCP_APP_RESOURCE_URI_PREFIX, } from './types.js';
18
- export type { McpAppActionDispatcherToolInput, McpAppActionToolDescriptor, McpAppActionToolInput, McpAppButtonDescriptor, McpAppButtonInput, McpAppDescriptor, McpAppDescriptorInput, McpAppInputSchema, McpAppTone, McpUiResourceCsp, McpAppRegistry, McpAppResource, McpAppServerStateInput, McpAppStateDescriptor, McpAppStateProjections, McpAppHostToolInput, McpAppHostToolName, McpAppReadToolInput, McpAppSingleActionToolInput, McpAppToolCommonInput, McpAppToolDescriptor, McpAppToolInput, McpAppToolMetadata, McpAppToolRegistration, McpAppToolResult, McpAppToolVisibility, McpAppInstanceResourceBinding, McpAppMcpResourceBinding, McpAppResourceBinding, McpAppLocalResource, McpAppLocalRegistrationInput, McpAppLocalReadToolDescriptor, McpAppLocalActionToolDescriptor, McpAppLocalToolDescriptor, McpAppLocalRegistration, McpAppBuiltinRegistration, McpAppResolvedRegistration, McpAppLocalLauncher, McpAppBuiltinLauncher, McpAppLauncher, WorkspaceAppLauncher, WorkspaceAppResolvedRegistration, McpAppWorkspaceRegistry, WorkspaceAppRegistry, McpAppWorkspaceRegistryInput, } from './types.js';
22
+ export type { McpAppActionDispatcherToolInput, McpAppActionToolDescriptor, McpAppActionToolInput, McpAppButtonDescriptor, McpAppButtonInput, McpAppDescriptor, McpAppDescriptorInput, McpAppInputSchema, McpAppTone, McpUiResourceCsp, McpAppRegistry, McpAppResource, McpAppServerStateInput, McpAppStateDescriptor, McpAppStateProjections, McpAppHostToolInput, McpAppHostToolName, McpAppReadToolInput, McpAppSingleActionToolInput, McpAppToolCommonInput, McpAppToolDescriptor, McpAppToolInput, McpAppToolMetadata, McpAppToolRegistration, McpAppToolResult, McpAppToolVisibility, McpAppInstanceResourceBinding, McpAppMcpResourceBinding, McpAppResourceBinding, McpAppLocalResource, McpAppLocalRegistrationInput, McpAppLocalReadToolDescriptor, McpAppLocalActionToolDescriptor, McpAppLocalSingleActionToolDescriptor, McpAppLocalToolDiagnostic, McpAppLocalToolDescriptor, McpAppLocalRegistration, McpAppBuiltinRegistration, McpAppResolvedRegistration, McpAppLocalLauncher, McpAppBuiltinLauncher, McpAppLauncher, WorkspaceAppLauncher, WorkspaceAppResolvedRegistration, McpAppWorkspaceRegistry, WorkspaceAppRegistry, McpAppWorkspaceRegistryInput, } from './types.js';
19
23
  export { buildWorkspaceAppSnapshot, discoverWorkspaceAppSnapshot, reconfirmWorkspaceAppSnapshot, } from './workspace-snapshot.js';
20
24
  export type { WorkspaceAppSnapshot, WorkspaceAppSnapshotBuildOptions, WorkspaceAppSnapshotOptions, WorkspaceAppSnapshotReconfirmResult, WorkspaceAppSnapshotResource, WorkspaceAppSnapshotInitialState, WorkspaceAppInitialState, } from './workspace-snapshot.js';
@@ -0,0 +1,26 @@
1
+ import type { JsonObject } from '../ui-instance/types.js';
2
+ export declare const MCP_APP_MODEL_CONTEXT_MAX_BYTES: number;
3
+ export declare const MCP_APP_MODEL_CONTEXT_MAX_STRING_LENGTH = 2048;
4
+ export declare const MCP_APP_MODEL_CONTEXT_MAX_ARRAY_LENGTH = 200;
5
+ export declare const MCP_APP_MODEL_CONTEXT_MAX_DEPTH = 8;
6
+ export interface McpAppModelContextInput {
7
+ readonly instanceId: string;
8
+ readonly definitionHash: string;
9
+ readonly revision: number;
10
+ readonly content?: unknown;
11
+ readonly structuredContent?: unknown;
12
+ }
13
+ export interface McpAppModelContext {
14
+ readonly instanceId: string;
15
+ readonly definitionHash: string;
16
+ readonly revision: number;
17
+ readonly content?: readonly {
18
+ readonly type: 'text';
19
+ readonly text: string;
20
+ }[];
21
+ readonly structuredContent?: JsonObject;
22
+ }
23
+ export declare function sanitizeMcpAppModelContext(value: unknown): McpAppModelContext;
24
+ export declare function serializeMcpAppModelContextXml(context: McpAppModelContext, options?: {
25
+ readonly stale?: boolean;
26
+ }): string;
@@ -1,10 +1,11 @@
1
1
  import type { JsonObject } from '../ui-instance/types.js';
2
2
  import type { McpAppServerStateInput, McpAppStateDescriptor, McpAppStateProjections, McpAppToolDescriptor, McpAppToolResult } from './types.js';
3
3
  export declare const MCP_APP_PROJECTION_MAX_BYTES: number;
4
+ export declare const SENSITIVE_KEY: RegExp;
4
5
  export declare function buildMcpAppStateDescriptor(input: McpAppServerStateInput): McpAppStateDescriptor;
5
6
  export declare function buildTerminalMcpAppStateDescriptor(input: McpAppServerStateInput): McpAppStateDescriptor;
6
7
  export declare function serializeMcpAppStateJson(descriptor: McpAppStateDescriptor, dataPaths?: readonly string[]): string;
7
- export declare function serializeMcpAppStateXml(descriptor: McpAppStateDescriptor, focusedAiDataPaths?: readonly string[]): string;
8
+ export declare function serializeMcpAppStateXml(descriptor: McpAppStateDescriptor): string;
8
9
  export declare function buildMcpAppStateProjections(input: McpAppServerStateInput): McpAppStateProjections;
9
10
  export declare function buildTerminalMcpAppStateProjections(input: McpAppServerStateInput): McpAppStateProjections;
10
11
  export declare function createMcpAppToolResult(tool: Pick<McpAppToolDescriptor, 'textFallback'>, options?: {
@@ -108,9 +108,17 @@ export interface McpAppLocalRegistrationInput {
108
108
  readonly initialStateBytes?: readonly number[];
109
109
  readonly readToolName: string;
110
110
  readonly actionToolName?: string;
111
+ readonly modelActions?: readonly string[];
111
112
  readonly actions: readonly {
112
113
  readonly actionId: string;
113
114
  readonly inputSchema: McpAppInputSchema;
115
+ readonly backend?: {
116
+ readonly type: 'core';
117
+ readonly handler: string;
118
+ } | {
119
+ readonly type: 'skill';
120
+ readonly command?: readonly string[];
121
+ };
114
122
  }[];
115
123
  }
116
124
  export interface McpAppLocalReadToolDescriptor extends McpAppToolCommonInput {
@@ -123,7 +131,23 @@ export interface McpAppLocalActionToolDescriptor extends McpAppToolCommonInput {
123
131
  readonly resourceBinding: McpAppInstanceResourceBinding;
124
132
  readonly actionIds: readonly string[];
125
133
  }
126
- export type McpAppLocalToolDescriptor = McpAppLocalReadToolDescriptor | McpAppLocalActionToolDescriptor;
134
+ export interface McpAppLocalSingleActionToolDescriptor extends McpAppToolCommonInput {
135
+ readonly kind: 'action';
136
+ readonly resourceBinding: McpAppInstanceResourceBinding;
137
+ readonly actionId: string;
138
+ readonly actionIds: readonly [string];
139
+ readonly _meta: {
140
+ readonly ui: {
141
+ readonly visibility: readonly McpAppToolVisibility[];
142
+ };
143
+ };
144
+ }
145
+ export interface McpAppLocalToolDiagnostic {
146
+ readonly toolName: string;
147
+ readonly actionId: string;
148
+ readonly reason: 'name_too_long' | 'name_collision';
149
+ }
150
+ export type McpAppLocalToolDescriptor = McpAppLocalReadToolDescriptor | McpAppLocalActionToolDescriptor | McpAppLocalSingleActionToolDescriptor;
127
151
  export interface McpAppLocalRegistration {
128
152
  readonly appId: string;
129
153
  readonly name: string;
@@ -135,6 +159,7 @@ export interface McpAppLocalRegistration {
135
159
  readonly resourceBinding: McpAppInstanceResourceBinding;
136
160
  readonly resource: McpAppLocalResource;
137
161
  readonly tools: readonly McpAppLocalToolDescriptor[];
162
+ readonly toolDiagnostics: readonly McpAppLocalToolDiagnostic[];
138
163
  }
139
164
  export interface McpAppBuiltinRegistration {
140
165
  readonly appId: string;
@@ -273,7 +298,6 @@ export interface McpAppStateDescriptor {
273
298
  readonly status: UiInstanceStatus;
274
299
  readonly state: JsonObject;
275
300
  readonly buttons: readonly McpAppButtonDescriptor[];
276
- readonly focusedAiDataPaths?: readonly string[];
277
301
  }
278
302
  export interface McpAppStateProjections {
279
303
  readonly descriptor: McpAppStateDescriptor;
@@ -0,0 +1,38 @@
1
+ CREATE TABLE IF NOT EXISTS `thread_creator_unverified` (
2
+ `thread_id` text NOT NULL,
3
+ `created_by_task_id` text NOT NULL,
4
+ PRIMARY KEY(`thread_id`, `created_by_task_id`)
5
+ );
6
+ --> statement-breakpoint
7
+ INSERT OR IGNORE INTO `thread_creator_unverified` (`thread_id`, `created_by_task_id`)
8
+ SELECT `id`, `created_by_task_id`
9
+ FROM `threads`
10
+ WHERE `created_by_task_id` IS NOT NULL
11
+ AND NOT EXISTS (
12
+ SELECT 1
13
+ FROM `sqlite_master`
14
+ WHERE `type` = 'trigger'
15
+ AND `name` = 'trg_threads_creator_late_fill_guard'
16
+ );
17
+ --> statement-breakpoint
18
+ CREATE TRIGGER IF NOT EXISTS `trg_threads_creator_late_fill_guard`
19
+ AFTER UPDATE OF `created_by_task_id` ON `threads`
20
+ WHEN OLD.`created_by_task_id` IS NULL
21
+ AND NEW.`created_by_task_id` IS NOT NULL
22
+ AND (
23
+ OLD.`message_count` <> 0
24
+ OR EXISTS (
25
+ SELECT 1
26
+ FROM `tasks`
27
+ WHERE `thread_id` = OLD.`id`
28
+ AND `id` <> NEW.`created_by_task_id`
29
+ )
30
+ )
31
+ BEGIN
32
+ UPDATE `threads`
33
+ SET `created_by_task_id` = NULL
34
+ WHERE `id` = NEW.`id`;
35
+ END;
36
+ --> statement-breakpoint
37
+ CREATE INDEX IF NOT EXISTS `idx_tasks_thread_creator`
38
+ ON `tasks` (`id`, `thread_id`, `actor_kind`, `actor_id`);
@@ -232,6 +232,13 @@
232
232
  "when": 1790121600000,
233
233
  "tag": "0032_ui_instance_opened_by",
234
234
  "breakpoints": true
235
+ },
236
+ {
237
+ "idx": 33,
238
+ "version": "6",
239
+ "when": 1790219126942,
240
+ "tag": "0033_thread_creator_boundary_guard",
241
+ "breakpoints": true
235
242
  }
236
243
  ]
237
244
  }
@@ -0,0 +1 @@
1
+ export { getLocalActorId, normalizeLocalActorId } from '../utils/local-identity.js';
@@ -0,0 +1,2 @@
1
+ 'use strict';var crypto=require('crypto'),i=require('fs'),p=require('os'),a=require('path');function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var i__namespace=/*#__PURE__*/_interopNamespace(i);var p__namespace=/*#__PURE__*/_interopNamespace(p);var a__namespace=/*#__PURE__*/_interopNamespace(a);function w(){if(process.env.CREWX_HOME){let n=a__namespace.resolve(process.env.CREWX_HOME);try{return i__namespace.realpathSync(n)}catch(t){if(t instanceof Error&&"code"in t&&t.code==="ENOENT")return n;throw t}}return process.platform!=="win32"&&process.env.XDG_CONFIG_HOME?a__namespace.join(process.env.XDG_CONFIG_HOME,"crewx"):a__namespace.join(p__namespace.homedir(),".crewx")}var x="identity.json",_=/^[a-z0-9._-]+@[a-z0-9._-]+$/,T=new Set(["system","local-service","network-service"]),d=new Map;function S(n){return n.trim().toLowerCase().replace(/[^a-z0-9._-]/g,"-").replace(/-+/g,"-").replace(/^-+|-+$/g,"")}function v(n,t){let e=n.trim();if(!e||e.endsWith("$"))return null;let r=S(e),o=t.trim().split(".",1)[0]??"",l=S(o);return !r||!l||T.has(r)?null:`${r}@${l}`}function C(n){return typeof n=="string"&&_.test(n)}function f(n){let t;try{t=i__namespace.readFileSync(n,"utf8");}catch(e){return e!==null&&typeof e=="object"&&"code"in e&&e.code==="ENOENT"?{kind:"missing"}:{kind:"failed"}}try{let e=JSON.parse(t);if(e!==null&&typeof e=="object"&&"id"in e&&C(e.id))return {kind:"valid",id:e.id}}catch{}return {kind:"invalid"}}function b(){let n=new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));Atomics.wait(n,0,0,20);}function u(n){let t=f(n);if(t.kind==="valid")return t.id;if(t.kind==="failed")return null;b();let e=f(n);return e.kind==="valid"?e.id:null}function A(n,t){let e,r=false;try{e=i__namespace.openSync(n,"wx",384),i__namespace.writeFileSync(e,t,"utf8"),r=!0;}catch{r=false;}if(e!==void 0)try{i__namespace.closeSync(e);}catch{r=false;}return r}function O(n,t){let e;try{e=i__namespace.openSync(n,"wx",384),i__namespace.writeFileSync(e,t,"utf8");}catch(r){if(e!==void 0)try{i__namespace.closeSync(e);}catch{}return r!==null&&typeof r=="object"&&"code"in r&&r.code==="EEXIST"?"exists":"failed"}try{i__namespace.closeSync(e);}catch{return "failed"}return "created"}function R(n,t){return n!==null&&typeof n=="object"&&"code"in n&&n.code===t}function F(){if((process.env.NODE_ENV==="test"||process.env.VITEST!==void 0)&&!process.env.CREWX_HOME)return null;let n;try{n=w();}catch{return null}let t=d.get(n);if(t)return t;let e=a.join(n,x),r=f(e);if(r.kind==="valid")return d.set(n,r.id),r.id;if(r.kind==="failed")return null;if(r.kind==="invalid"){let s=u(e);return s&&d.set(n,s),s}let o;try{o=v(p__namespace.userInfo().username,p__namespace.hostname());}catch{return null}if(!o)return null;let l=`${JSON.stringify({id:o})}
2
+ `,m=a.join(n,`.identity-${process.pid}-${crypto.randomUUID()}.tmp`);try{if(i__namespace.mkdirSync(n,{recursive:!0,mode:448}),!A(m,l))return null;let s=f(e);if(s.kind==="valid")return d.set(n,s.id),s.id;if(s.kind==="invalid"){let c=u(e);return c&&d.set(n,c),c}if(s.kind==="failed")return null;try{return i__namespace.linkSync(m,e),d.set(n,o),o}catch(c){if(R(c,"EEXIST")){let y=u(e);return y&&d.set(n,y),y}}let E=O(e,l);if(E==="created")return d.set(n,o),o;if(E==="exists"){let c=u(e);return c&&d.set(n,c),c}return null}catch{return null}finally{try{i__namespace.unlinkSync(m);}catch{}}}exports.getLocalActorId=F;exports.normalizeLocalActorId=v;