@crewx/sdk 0.9.0-rc.164 → 0.9.0-rc.165
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.
- package/dist/app/app.d.ts +10 -0
- package/dist/app/entry.d.ts +2 -0
- package/dist/app/index.d.ts +6 -0
- package/dist/app/index.js +12 -10
- package/dist/app/job-bridge.child.d.ts +1 -0
- package/dist/app/job-bridge.d.ts +67 -0
- package/dist/app/job-bridge.drain.child.d.ts +1 -0
- package/dist/app/job-bridge.example.d.ts +11 -0
- package/dist/app/job-contract.d.ts +40 -0
- package/dist/app/job-wire.d.ts +149 -0
- package/dist/app/runtime.d.ts +2 -0
- package/dist/app-artifact-policy/check.d.ts +2 -0
- package/dist/app-artifact-policy/contract.d.ts +54 -0
- package/dist/app-artifact-policy/helper.d.ts +15 -0
- package/dist/app-artifact-policy/index.d.ts +3 -0
- package/dist/app-artifact-policy/index.js +18 -0
- package/dist/app-artifact-policy/paths.d.ts +24 -0
- package/dist/app-artifact-policy/scan.d.ts +47 -0
- package/dist/desktop/index.js +3 -3
- package/dist/esm/app/index.js +12 -10
- package/dist/esm/app-artifact-policy/index.js +18 -0
- package/dist/esm/desktop/index.js +3 -3
- package/dist/esm/index.js +234 -232
- package/dist/esm/plugins/index.js +27 -27
- package/dist/esm/process/index.js +1 -1
- package/dist/esm/publish/index.js +2 -2
- package/dist/esm/repository/index.js +30 -30
- package/dist/esm/skills/index.js +2 -2
- package/dist/index.browser.d.ts +4 -0
- package/dist/index.browser.js +4 -4
- package/dist/index.d.ts +10 -2
- package/dist/index.js +240 -238
- package/dist/mcp-app/app-job-bridge.d.ts +30 -0
- package/dist/mcp-app/app-job-bridge.example.d.ts +36 -0
- package/dist/mcp-app/app-job.d.ts +168 -0
- package/dist/mcp-app/index.d.ts +4 -0
- package/dist/mcp-app/skill-backend.d.ts +7 -1
- package/dist/plugins/index.js +20 -20
- package/dist/process/index.d.ts +2 -2
- package/dist/process/index.js +1 -1
- package/dist/process/process-control.d.ts +19 -0
- package/dist/publish/index.js +2 -2
- package/dist/repository/index.js +37 -37
- package/dist/skills/index.js +2 -2
- package/dist/ui-instance/types.d.ts +6 -0
- package/dist/ui-plugin/types.d.ts +4 -1
- package/package.json +7 -1
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type AppJobChannel, type AppJobView, type AppJobWireHandle } from '../app/job-wire.js';
|
|
2
|
+
import type { AppJobOperation, AppJobStopReason, AppJobTrigger } from '../app/job-contract.js';
|
|
3
|
+
import { AppJobCoordinator, type AppJobHandle, type AppJobLaunchRequest, type AppJobOwner, type AppJobSnapshot, type ResolvedAppJob } from './app-job.js';
|
|
4
|
+
export interface AppJobControlSession {
|
|
5
|
+
readonly coordinator: AppJobCoordinator;
|
|
6
|
+
readonly owner: AppJobOwner;
|
|
7
|
+
readonly definitionHash: string;
|
|
8
|
+
readonly job: ResolvedAppJob | undefined;
|
|
9
|
+
readonly actionId: string;
|
|
10
|
+
readonly operations: readonly AppJobOperation[];
|
|
11
|
+
readonly trigger: AppJobTrigger;
|
|
12
|
+
}
|
|
13
|
+
export type AppJobControlAnswer = {
|
|
14
|
+
readonly kind: 'reply';
|
|
15
|
+
readonly line: string;
|
|
16
|
+
} | {
|
|
17
|
+
readonly kind: 'close';
|
|
18
|
+
readonly code: 'APP_JOB_BRIDGE_INVALID';
|
|
19
|
+
};
|
|
20
|
+
export declare function answerAppJobControlLine(session: AppJobControlSession, line: string): AppJobControlAnswer;
|
|
21
|
+
export interface AppJobRunBinding {
|
|
22
|
+
readonly coordinator: AppJobCoordinator;
|
|
23
|
+
readonly handle: AppJobHandle;
|
|
24
|
+
}
|
|
25
|
+
export type AppJobRunAnswer = 'accepted' | 'ignored' | 'invalid';
|
|
26
|
+
export declare function answerAppJobRunLine(binding: AppJobRunBinding, line: string): AppJobRunAnswer;
|
|
27
|
+
export declare function encodeAppJobStopPush(handle: AppJobWireHandle, reason: AppJobStopReason): string;
|
|
28
|
+
export declare function toAppJobView(snapshot: AppJobSnapshot): AppJobView;
|
|
29
|
+
export declare function buildAppJobRunChannel(request: Pick<AppJobLaunchRequest, 'handle'>, fd: number): AppJobChannel;
|
|
30
|
+
export declare function buildAppJobControlChannel(operations: readonly AppJobOperation[], fd: number): AppJobChannel;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { UiDefinitionInput } from '../ui-instance/types.js';
|
|
2
|
+
import { type AppJobControlSession } from './app-job-bridge.js';
|
|
3
|
+
import { AppJobCoordinator, type AppJobOwner } from './app-job.js';
|
|
4
|
+
export declare const CODE_MAP_HOST_FD = 3;
|
|
5
|
+
export interface HostPipeEnd {
|
|
6
|
+
write(line: string): void;
|
|
7
|
+
onData(listener: (chunk: string) => void): void;
|
|
8
|
+
onEnd(listener: () => void): void;
|
|
9
|
+
close(): void;
|
|
10
|
+
}
|
|
11
|
+
export interface HostChild {
|
|
12
|
+
readonly pipe: HostPipeEnd;
|
|
13
|
+
kill(): Promise<void>;
|
|
14
|
+
}
|
|
15
|
+
export type HostSpawn = (options: {
|
|
16
|
+
readonly env: Readonly<Record<string, string>>;
|
|
17
|
+
readonly fd: number;
|
|
18
|
+
}) => HostChild;
|
|
19
|
+
export interface CodeMapHostOptions {
|
|
20
|
+
readonly owner: AppJobOwner;
|
|
21
|
+
readonly definitionHash: string;
|
|
22
|
+
readonly definition: UiDefinitionInput;
|
|
23
|
+
readonly spawnRun: HostSpawn;
|
|
24
|
+
readonly now: () => number;
|
|
25
|
+
readonly stopGraceMs?: number;
|
|
26
|
+
readonly newRunId?: () => string;
|
|
27
|
+
}
|
|
28
|
+
export interface CodeMapHost {
|
|
29
|
+
readonly coordinator: AppJobCoordinator;
|
|
30
|
+
sessionFor(call: {
|
|
31
|
+
readonly actionId: string;
|
|
32
|
+
readonly actorKind: 'user' | 'agent' | 'schedule';
|
|
33
|
+
}): AppJobControlSession;
|
|
34
|
+
serveControlChild(session: AppJobControlSession, pipe: HostPipeEnd): void;
|
|
35
|
+
}
|
|
36
|
+
export declare function createCodeMapHost(options: CodeMapHostOptions): CodeMapHost;
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { type AppJobOutcome, type AppJobRefusalCode, type AppJobState, type AppJobStopReason, type AppJobTrigger } from '../app/job-contract.js';
|
|
2
|
+
export type { AppJobRefusalCode, AppJobStopReason } from '../app/job-contract.js';
|
|
3
|
+
import type { UiDefinitionInput } from '../ui-instance/types.js';
|
|
4
|
+
import type { AppScheduleOwnerSource } from './app-schedule.js';
|
|
5
|
+
export interface AppJobOwner {
|
|
6
|
+
readonly workspaceId: string;
|
|
7
|
+
readonly appId: string;
|
|
8
|
+
readonly source: AppScheduleOwnerSource;
|
|
9
|
+
}
|
|
10
|
+
export interface ResolvedAppJob {
|
|
11
|
+
readonly actionId: string;
|
|
12
|
+
readonly deadlineMs: number;
|
|
13
|
+
}
|
|
14
|
+
export declare function resolveDeclaredJob(definition: Pick<UiDefinitionInput, 'actions'>): ResolvedAppJob | undefined;
|
|
15
|
+
export declare function appJobOwnerKey(owner: AppJobOwner): string;
|
|
16
|
+
export interface AppJobError {
|
|
17
|
+
readonly code: string;
|
|
18
|
+
readonly recoverable: boolean;
|
|
19
|
+
}
|
|
20
|
+
export interface AppJobHandle {
|
|
21
|
+
readonly runId: string;
|
|
22
|
+
readonly generation: number;
|
|
23
|
+
readonly ownerKey: string;
|
|
24
|
+
}
|
|
25
|
+
export interface AppJobLaunchRequest {
|
|
26
|
+
readonly handle: AppJobHandle;
|
|
27
|
+
readonly owner: AppJobOwner;
|
|
28
|
+
readonly actionId: string;
|
|
29
|
+
readonly definitionHash: string;
|
|
30
|
+
readonly deadlineMs: number;
|
|
31
|
+
readonly trigger: AppJobTrigger;
|
|
32
|
+
readonly resumeFromRunId: string | null;
|
|
33
|
+
}
|
|
34
|
+
export interface AppJobExecutionPort {
|
|
35
|
+
launch(request: AppJobLaunchRequest): Promise<string>;
|
|
36
|
+
requestStop(ref: string): Promise<void>;
|
|
37
|
+
terminate(ref: string): Promise<void>;
|
|
38
|
+
}
|
|
39
|
+
export type AppJobReport = {
|
|
40
|
+
readonly kind: 'heartbeat';
|
|
41
|
+
} | {
|
|
42
|
+
readonly kind: 'progress';
|
|
43
|
+
readonly phase: string;
|
|
44
|
+
readonly completed?: number;
|
|
45
|
+
readonly total?: number;
|
|
46
|
+
readonly resumable?: boolean;
|
|
47
|
+
} | {
|
|
48
|
+
readonly kind: 'completed';
|
|
49
|
+
} | {
|
|
50
|
+
readonly kind: 'failed';
|
|
51
|
+
readonly code: string;
|
|
52
|
+
readonly recoverable: boolean;
|
|
53
|
+
} | {
|
|
54
|
+
readonly kind: 'exited';
|
|
55
|
+
};
|
|
56
|
+
export type AppJobReportResult = 'accepted' | 'ignored' | 'invalid';
|
|
57
|
+
export interface AppJobStartRequest {
|
|
58
|
+
readonly owner: AppJobOwner;
|
|
59
|
+
readonly definitionHash: string;
|
|
60
|
+
readonly job: ResolvedAppJob | undefined;
|
|
61
|
+
readonly trigger: AppJobTrigger;
|
|
62
|
+
readonly authorizedActionId: string;
|
|
63
|
+
}
|
|
64
|
+
export type AppJobStartRefusalCode = Extract<AppJobRefusalCode, ('APP_JOB_NOT_DECLARED' | 'APP_JOB_NOT_AUTHORIZED' | 'APP_JOB_SELF_START' | 'APP_JOB_OWNER_INVALID' | 'APP_JOB_DEFINITION_INVALID' | 'APP_JOB_DEFINITION_CHANGED' | 'APP_JOB_DEADLINE_INVALID' | 'APP_JOB_SHUTTING_DOWN')>;
|
|
65
|
+
export type AppJobStartResult = {
|
|
66
|
+
readonly kind: 'started';
|
|
67
|
+
readonly snapshot: AppJobSnapshot;
|
|
68
|
+
} | {
|
|
69
|
+
readonly kind: 'attached';
|
|
70
|
+
readonly snapshot: AppJobSnapshot;
|
|
71
|
+
} | {
|
|
72
|
+
readonly kind: 'refused';
|
|
73
|
+
readonly code: AppJobStartRefusalCode;
|
|
74
|
+
};
|
|
75
|
+
export type AppJobCancelRefusalCode = 'APP_JOB_OWNER_MISMATCH' | 'APP_JOB_STALE_HANDLE' | 'APP_JOB_NOT_ACTIVE';
|
|
76
|
+
export type AppJobCancelResult = {
|
|
77
|
+
readonly kind: 'stopping';
|
|
78
|
+
readonly snapshot: AppJobSnapshot;
|
|
79
|
+
} | {
|
|
80
|
+
readonly kind: 'refused';
|
|
81
|
+
readonly code: AppJobCancelRefusalCode;
|
|
82
|
+
};
|
|
83
|
+
export interface AppJobSnapshot {
|
|
84
|
+
readonly handle: AppJobHandle;
|
|
85
|
+
readonly state: AppJobState;
|
|
86
|
+
readonly stopReason: AppJobStopReason | null;
|
|
87
|
+
readonly trigger: AppJobTrigger;
|
|
88
|
+
readonly definitionHash: string;
|
|
89
|
+
readonly resumedFromRunId: string | null;
|
|
90
|
+
readonly outcome: AppJobOutcome | null;
|
|
91
|
+
readonly phase: string | null;
|
|
92
|
+
readonly completed: number | null;
|
|
93
|
+
readonly total: number | null;
|
|
94
|
+
readonly resumable: boolean;
|
|
95
|
+
readonly lastHeartbeatAt: string | null;
|
|
96
|
+
readonly startedAt: string;
|
|
97
|
+
readonly finishedAt: string | null;
|
|
98
|
+
readonly error: AppJobError | null;
|
|
99
|
+
}
|
|
100
|
+
export interface AppJobRecord {
|
|
101
|
+
readonly runId: string;
|
|
102
|
+
readonly owner: AppJobOwner;
|
|
103
|
+
readonly generation: number;
|
|
104
|
+
readonly actionId: string;
|
|
105
|
+
readonly definitionHash: string;
|
|
106
|
+
readonly deadlineMs: number;
|
|
107
|
+
readonly trigger: AppJobTrigger;
|
|
108
|
+
readonly resumedFromRunId: string | null;
|
|
109
|
+
readonly state: AppJobState;
|
|
110
|
+
readonly outcome: AppJobOutcome | null;
|
|
111
|
+
readonly phase: string | null;
|
|
112
|
+
readonly completed: number | null;
|
|
113
|
+
readonly total: number | null;
|
|
114
|
+
readonly resumable: boolean;
|
|
115
|
+
readonly startedAt: number;
|
|
116
|
+
readonly lastHeartbeatAt: number | null;
|
|
117
|
+
readonly finishedAt: number | null;
|
|
118
|
+
readonly error: AppJobError | null;
|
|
119
|
+
}
|
|
120
|
+
export interface AppJobEvent {
|
|
121
|
+
readonly kind: 'started' | 'attached' | 'stop_requested' | 'finished';
|
|
122
|
+
readonly runId: string;
|
|
123
|
+
readonly generation: number;
|
|
124
|
+
readonly owner: AppJobOwner;
|
|
125
|
+
readonly trigger: AppJobTrigger;
|
|
126
|
+
readonly stopReason: AppJobStopReason | null;
|
|
127
|
+
readonly outcome: AppJobOutcome | null;
|
|
128
|
+
readonly errorCode: string | null;
|
|
129
|
+
readonly at: string;
|
|
130
|
+
}
|
|
131
|
+
export interface AppJobCoordinatorOptions {
|
|
132
|
+
readonly port: AppJobExecutionPort;
|
|
133
|
+
readonly now: () => number;
|
|
134
|
+
readonly records?: readonly AppJobRecord[];
|
|
135
|
+
readonly onEvent?: (event: AppJobEvent) => void;
|
|
136
|
+
readonly newRunId?: () => string;
|
|
137
|
+
readonly stopGraceMs?: number;
|
|
138
|
+
}
|
|
139
|
+
export declare class AppJobCoordinator {
|
|
140
|
+
private readonly port;
|
|
141
|
+
private readonly now;
|
|
142
|
+
private readonly newRunId;
|
|
143
|
+
private readonly onEvent;
|
|
144
|
+
private readonly stopGraceMs;
|
|
145
|
+
private readonly runs;
|
|
146
|
+
private readonly latestByOwner;
|
|
147
|
+
private readonly drainWaiters;
|
|
148
|
+
private shuttingDown;
|
|
149
|
+
constructor(options: AppJobCoordinatorOptions);
|
|
150
|
+
start(request: AppJobStartRequest): AppJobStartResult;
|
|
151
|
+
cancel(handle: AppJobHandle): AppJobCancelResult;
|
|
152
|
+
report(handle: AppJobHandle, report: AppJobReport): AppJobReportResult;
|
|
153
|
+
status(owner: AppJobOwner): AppJobSnapshot | null;
|
|
154
|
+
tick(): void;
|
|
155
|
+
shutdown(): Promise<void>;
|
|
156
|
+
records(): readonly AppJobRecord[];
|
|
157
|
+
private launch;
|
|
158
|
+
private beginStop;
|
|
159
|
+
private requestStop;
|
|
160
|
+
private terminate;
|
|
161
|
+
private finish;
|
|
162
|
+
private restore;
|
|
163
|
+
private settle;
|
|
164
|
+
private emit;
|
|
165
|
+
private unfinishedCount;
|
|
166
|
+
private drain;
|
|
167
|
+
private snapshot;
|
|
168
|
+
}
|
package/dist/mcp-app/index.d.ts
CHANGED
|
@@ -39,3 +39,7 @@ export { buildWorkspaceAppSnapshot, discoverWorkspaceAppSnapshot, reconfirmWorks
|
|
|
39
39
|
export type { WorkspaceAppSnapshot, WorkspaceAppSnapshotBuildOptions, WorkspaceAppSnapshotOptions, WorkspaceAppSnapshotReconfirmResult, WorkspaceAppSnapshotResource, WorkspaceAppSnapshotInitialState, WorkspaceAppInitialState, } from './workspace-snapshot.js';
|
|
40
40
|
export { appScheduleCommandLabel, cronExpressionForInterval, decideScheduleDirective, planScheduledFire, resolveDeclaredSchedule, scheduleTemplateFor, toScheduledRunVerdict, toScheduleSnapshot, } from './app-schedule.js';
|
|
41
41
|
export type { AppScheduleActorKind, AppScheduleAvailability, AppScheduleBinding, AppScheduleOwner, AppScheduleOwnerSource, AppScheduleRowView, AppScheduleTemplate, AppScheduledRunPayload, AppScheduledRunPlan, ResolvedAppSchedule, ScheduleDirectiveDecision, ScheduleLifecycleEntry, ScheduleLifecyclePlan, ScheduledAppLaunchRequest, } from './app-schedule.js';
|
|
42
|
+
export { AppJobCoordinator, appJobOwnerKey, resolveDeclaredJob, } from './app-job.js';
|
|
43
|
+
export type { AppJobCancelRefusalCode, AppJobCancelResult, AppJobCoordinatorOptions, AppJobError, AppJobEvent, AppJobExecutionPort, AppJobHandle, AppJobLaunchRequest, AppJobOwner, AppJobRecord, AppJobRefusalCode, AppJobReport, AppJobReportResult, AppJobSnapshot, AppJobStartRefusalCode, AppJobStartRequest, AppJobStartResult, AppJobStopReason, ResolvedAppJob, } from './app-job.js';
|
|
44
|
+
export { answerAppJobControlLine, answerAppJobRunLine, buildAppJobControlChannel, buildAppJobRunChannel, encodeAppJobStopPush, toAppJobView, } from './app-job-bridge.js';
|
|
45
|
+
export type { AppJobControlAnswer, AppJobControlSession, AppJobRunAnswer, AppJobRunBinding, } from './app-job-bridge.js';
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { SKILL_BACKEND_CONTENT_SCHEMA_VERSION, SKILL_BACKEND_MAX_INPUT_BYTES, SKILL_BACKEND_MAX_OUTPUT_BYTES } from '../app/protocol.js';
|
|
2
2
|
import { type AppScheduleDirective, type AppScheduleSnapshot } from '../app/schedule-contract.js';
|
|
3
|
+
import type { AppJobOperation } from '../app/job-contract.js';
|
|
4
|
+
import { type AppJobChannel } from '../app/job-wire.js';
|
|
3
5
|
import type { ContentFrame, UiContentMediaType, UiContentRangeRequest } from './content-channel.js';
|
|
4
6
|
import type { JsonObject, UiExternalActionHandlerRegistration, UiSkillBackendEnvironmentKey } from '../ui-instance/types.js';
|
|
5
7
|
import type { UiPluginNormalizedManifestV2 } from '../ui-plugin/types.js';
|
|
@@ -71,6 +73,7 @@ interface SkillBackendExecutionRequestBase {
|
|
|
71
73
|
};
|
|
72
74
|
};
|
|
73
75
|
readonly environment?: Readonly<Partial<Record<UiSkillBackendEnvironmentKey, string>>>;
|
|
76
|
+
readonly jobAccess?: readonly AppJobOperation[];
|
|
74
77
|
}
|
|
75
78
|
export type SkillBackendExecutionRequest = SkillBackendExecutionRequestBase & ({
|
|
76
79
|
readonly source: 'bundled';
|
|
@@ -86,8 +89,11 @@ export interface SkillBackendChildEnvironment {
|
|
|
86
89
|
readonly CREWX_APP_REQUEST_ID: string;
|
|
87
90
|
readonly CREWX_APP_NOW_MS: string;
|
|
88
91
|
readonly CREWX_APP_ACTOR_KIND: 'user' | 'agent' | 'schedule';
|
|
92
|
+
readonly CREWX_APP_JOB_CHANNEL?: string;
|
|
89
93
|
}
|
|
90
|
-
export declare function buildSkillBackendChildEnvironment(request: Pick<SkillBackendExecutionRequest, 'requestId' | 'reservationNowMs' | 'actorKind'
|
|
94
|
+
export declare function buildSkillBackendChildEnvironment(request: Pick<SkillBackendExecutionRequest, 'requestId' | 'reservationNowMs' | 'actorKind'>, options?: {
|
|
95
|
+
readonly jobChannel?: AppJobChannel;
|
|
96
|
+
}): SkillBackendChildEnvironment;
|
|
91
97
|
export interface VerifiedBundleSkillSpawnRequest {
|
|
92
98
|
readonly appId: string;
|
|
93
99
|
readonly packageDir: string;
|