@crewx/sdk 0.9.0-rc.8 → 0.9.0-rc.80
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/README.md +1 -1
- package/dist/activity-log/builder.d.ts +55 -6
- package/dist/config/canonicalize-agent-options.d.ts +17 -0
- package/dist/config/global-settings.d.ts +33 -0
- package/dist/config/migrate-grok-mode.d.ts +6 -0
- package/dist/config/model-compat.d.ts +31 -0
- package/dist/config/models.generated.d.ts +33 -0
- package/dist/config/models.remote.d.ts +1 -0
- package/dist/config/overdrive.d.ts +7 -0
- package/dist/config/pricing.d.ts +8 -5
- package/dist/config/pricing.generated.d.ts +4 -0
- package/dist/config/pricing.types.d.ts +4 -10
- package/dist/config/timeout.config.d.ts +3 -0
- package/dist/config/wi-boards.d.ts +19 -0
- package/dist/context-budget/continuity.d.ts +61 -0
- package/dist/context-budget/index.d.ts +140 -0
- package/dist/conversation/index.d.ts +1 -1
- package/dist/conversation/sqlite-provider.d.ts +5 -1
- package/dist/conversation/to-template-messages.d.ts +7 -0
- package/dist/conversation/types.d.ts +43 -0
- package/dist/desktop/command-runner.d.ts +4 -0
- package/dist/desktop/default-adapters.d.ts +4 -0
- package/dist/desktop/global-install.d.ts +19 -0
- package/dist/desktop/index.d.ts +2 -0
- package/dist/desktop/index.js +3 -0
- package/dist/desktop/install.d.ts +5 -0
- package/dist/desktop/lnk.d.ts +22 -0
- package/dist/desktop/manifest.d.ts +21 -0
- package/dist/desktop/types.d.ts +67 -0
- package/dist/desktop/version.d.ts +1 -0
- package/dist/desktop/windows-paths.d.ts +21 -0
- package/dist/desktop/wrapper.d.ts +18 -0
- package/dist/esm/desktop/index.js +3 -0
- package/dist/esm/index.js +345 -96
- package/dist/esm/plugins/index.js +187 -93
- package/dist/esm/publish/index.js +1 -0
- package/dist/esm/repository/index.js +203 -94
- package/dist/esm/testing/index.js +1 -1
- package/dist/events/types.d.ts +4 -0
- package/dist/facade/Crewx.d.ts +38 -2
- package/dist/highlight/thread-highlight-prompt.d.ts +2 -0
- package/dist/highlight/thread-highlighter.d.ts +326 -0
- package/dist/index.browser.d.ts +9 -1
- package/dist/index.browser.js +6 -2
- package/dist/index.d.ts +57 -8
- package/dist/index.js +345 -96
- package/dist/internal/windows-spawn.d.ts +10 -0
- package/dist/layout/types.d.ts +17 -1
- package/dist/local-server/base-url.d.ts +18 -0
- package/dist/local-server/index.d.ts +8 -0
- package/dist/local-server/opencode.d.ts +8 -0
- package/dist/local-server/probe.d.ts +3 -0
- package/dist/local-server/runtime.d.ts +26 -0
- package/dist/local-server/types.d.ts +43 -0
- package/dist/migrations/0008_careful_black_bird.sql +17 -0
- package/dist/migrations/0009_hot_dark_phoenix.sql +1 -0
- package/dist/migrations/0010_analyze_stats.sql +6 -0
- package/dist/migrations/0011_far_black_tarantula.sql +1 -0
- package/dist/migrations/0012_blue_turbo.sql +23 -0
- package/dist/migrations/0013_hesitant_adam_destine.sql +15 -0
- package/dist/migrations/0014_organic_mongu.sql +73 -0
- package/dist/migrations/0015_panoramic_gorilla_man.sql +71 -0
- package/dist/migrations/0016_fuzzy_hemingway.sql +14 -0
- package/dist/migrations/0017_project_stage_sdk_migration.sql +29 -0
- package/dist/migrations/0018_bored_jackal.sql +33 -0
- package/dist/migrations/0019_backfill_task_thread_ids.sql +74 -0
- package/dist/migrations/0020_useful_iron_lad.sql +55 -0
- package/dist/migrations/0021_dashing_peter_quill.sql +51 -0
- package/dist/migrations/meta/0008_snapshot.json +1327 -0
- package/dist/migrations/meta/0009_snapshot.json +1335 -0
- package/dist/migrations/meta/0010_snapshot.json +1335 -0
- package/dist/migrations/meta/0011_snapshot.json +1342 -0
- package/dist/migrations/meta/0012_snapshot.json +1494 -0
- package/dist/migrations/meta/0013_snapshot.json +1592 -0
- package/dist/migrations/meta/0014_snapshot.json +1975 -0
- package/dist/migrations/meta/0015_snapshot.json +2315 -0
- package/dist/migrations/meta/0016_snapshot.json +2419 -0
- package/dist/migrations/meta/0017_snapshot.json +2419 -0
- package/dist/migrations/meta/0018_snapshot.json +2570 -0
- package/dist/migrations/meta/0020_snapshot.json +2895 -0
- package/dist/migrations/meta/0021_snapshot.json +3031 -0
- package/dist/migrations/meta/_journal.json +98 -0
- package/dist/paths.d.ts +1 -0
- package/dist/plugin/types.d.ts +1 -0
- package/dist/plugins/index.js +187 -93
- package/dist/plugins/sqlite-tracing.d.ts +22 -0
- package/dist/provider/acp/connection.d.ts +4 -0
- package/dist/provider/acp/meta.d.ts +11 -0
- package/dist/provider/bridge.d.ts +6 -0
- package/dist/provider/classify-task-error.d.ts +2 -0
- package/dist/provider/cli/adapter.types.d.ts +6 -0
- package/dist/provider/cli/adapters/cli-knob.util.d.ts +7 -0
- package/dist/provider/cli/adapters/grok.d.ts +2 -0
- package/dist/provider/cli/adapters/index.d.ts +1 -0
- package/dist/provider/cli/index.d.ts +1 -1
- package/dist/provider/cli/meta.d.ts +5 -0
- package/dist/provider/errors.d.ts +1 -0
- package/dist/provider/idle-watchdog.d.ts +19 -0
- package/dist/provider/models.d.ts +17 -12
- package/dist/provider/order.d.ts +1 -1
- package/dist/provider/parse-usage.d.ts +6 -0
- package/dist/provider/provider-selection.d.ts +8 -0
- package/dist/provider/redact-technical-message.d.ts +1 -0
- package/dist/provider/task-error.types.d.ts +16 -0
- package/dist/publish/auth-boundary.d.ts +22 -0
- package/dist/publish/auth-json.d.ts +11 -0
- package/dist/publish/constants.d.ts +6 -0
- package/dist/publish/index.d.ts +30 -0
- package/dist/publish/index.js +1 -0
- package/dist/publish/manifest.d.ts +17 -0
- package/dist/publish/marketplace-api.constants.d.ts +1 -0
- package/dist/publish/pack.d.ts +2 -0
- package/dist/publish/scan.d.ts +9 -0
- package/dist/publish/secrets.d.ts +6 -0
- package/dist/publish/upload.d.ts +18 -0
- package/dist/repository/agent-suggestion.repository.d.ts +34 -0
- package/dist/repository/common-code.repository.d.ts +39 -0
- package/dist/repository/db.d.ts +8 -0
- package/dist/repository/index.d.ts +28 -4
- package/dist/repository/index.js +203 -94
- package/dist/repository/notification.repository.d.ts +58 -0
- package/dist/repository/project.repository.d.ts +90 -0
- package/dist/repository/request-log.repository.d.ts +1 -0
- package/dist/repository/task-log-migration.d.ts +74 -0
- package/dist/repository/task-log.repository.d.ts +44 -0
- package/dist/repository/task.repository.d.ts +119 -0
- package/dist/repository/thread-history.repository.d.ts +193 -0
- package/dist/repository/thread-title-common-code-migration.d.ts +13 -0
- package/dist/repository/thread-title.types.d.ts +29 -0
- package/dist/repository/thread.repository.d.ts +21 -2
- package/dist/repository/usage-report.repository.d.ts +27 -0
- package/dist/schema/agent-suggestions.d.ts +199 -0
- package/dist/schema/common-codes.d.ts +216 -0
- package/dist/schema/index.d.ts +9 -0
- package/dist/schema/notifications.d.ts +303 -0
- package/dist/schema/projects.d.ts +610 -0
- package/dist/schema/task-log-events.d.ts +119 -0
- package/dist/schema/tasks.d.ts +53 -0
- package/dist/schema/thread-history.d.ts +734 -0
- package/dist/schema/threads.d.ts +2 -0
- package/dist/schema/ui-action-receipts.d.ts +303 -0
- package/dist/schema/ui-instances.d.ts +267 -0
- package/dist/schema/usage-reports.d.ts +252 -0
- package/dist/testing/index.js +1 -1
- package/dist/types/index.d.ts +1536 -3
- package/dist/ui-card/index.d.ts +2 -0
- package/dist/ui-card/legacy-card-parser.d.ts +11 -0
- package/dist/ui-instance/definition.d.ts +6 -0
- package/dist/ui-instance/errors.d.ts +17 -0
- package/dist/ui-instance/index.d.ts +6 -0
- package/dist/ui-instance/json.d.ts +5 -0
- package/dist/ui-instance/runtime.d.ts +13 -0
- package/dist/ui-instance/store.d.ts +65 -0
- package/dist/ui-instance/types.d.ts +200 -0
- package/dist/ui-plugin/index.d.ts +3 -0
- package/dist/ui-plugin/manifest.d.ts +3 -0
- package/dist/ui-plugin/types.d.ts +76 -0
- package/dist/ui-plugin/validator.d.ts +9 -0
- package/dist/utils/crewx-home.d.ts +1 -0
- package/dist/utils/id.d.ts +1 -1
- package/dist/utils/timestamp.d.ts +1 -0
- package/dist/wi/create.d.ts +48 -0
- package/dist/wi/select.d.ts +20 -0
- package/package.json +18 -2
- package/templates/agents/default.yaml +240 -116
- package/templates/documents/crewx-manual.md +138 -138
- package/templates/workflows/wi-default-flow.yaml +65 -0
- package/templates/workflows/wi-plan-flow.yaml +140 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface LegacyUiCardTag {
|
|
2
|
+
start: number;
|
|
3
|
+
end: number;
|
|
4
|
+
raw: string;
|
|
5
|
+
closed: boolean;
|
|
6
|
+
attrs: Readonly<Record<string, string>>;
|
|
7
|
+
privileged: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare function scanLegacyUiCardAt(text: string, start: number): LegacyUiCardTag;
|
|
10
|
+
export declare function scanLegacyUiCardTags(text: string): LegacyUiCardTag[];
|
|
11
|
+
export declare function extractLegacyWorkflowRunId(text: string | null | undefined): string | undefined;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { UiDefinition, UiDefinitionInput, UiDefinitionRef } from './types.js';
|
|
2
|
+
export declare function hashUiDefinition(input: UiDefinitionInput): string;
|
|
3
|
+
export declare function definitionKey(ref: UiDefinitionRef): string;
|
|
4
|
+
export declare function validateDefinition(definition: UiDefinition): void;
|
|
5
|
+
export declare function isExactCapability(value: string): boolean;
|
|
6
|
+
export declare function refFromDefinition(definition: UiDefinition): UiDefinitionRef;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export type UiRuntimeErrorCode = 'UNAUTHENTICATED' | 'INSTANCE_NOT_FOUND' | 'WORKSPACE_MISMATCH' | 'INSTANCE_NOT_ACTIONABLE' | 'DEFINITION_UNSUPPORTED' | 'CAPABILITY_DENIED' | 'INPUT_INVALID' | 'REVISION_CONFLICT' | 'ACTION_UNAVAILABLE' | 'HANDLER_NOT_FOUND' | 'ACTION_IN_FLIGHT' | 'DOMAIN_REJECTED' | 'EXECUTION_FAILED';
|
|
2
|
+
export declare class UiRuntimeError extends Error {
|
|
3
|
+
readonly code: UiRuntimeErrorCode;
|
|
4
|
+
readonly currentRevision?: number | undefined;
|
|
5
|
+
readonly name = "UiRuntimeError";
|
|
6
|
+
constructor(code: UiRuntimeErrorCode, message?: string, currentRevision?: number | undefined);
|
|
7
|
+
}
|
|
8
|
+
export declare class UiRetryableDatabaseError extends Error {
|
|
9
|
+
readonly cause: unknown;
|
|
10
|
+
readonly name = "UiRetryableDatabaseError";
|
|
11
|
+
constructor(cause: unknown);
|
|
12
|
+
}
|
|
13
|
+
export declare class UiReservationConflictError extends Error {
|
|
14
|
+
readonly currentRevision: number;
|
|
15
|
+
readonly name = "UiReservationConflictError";
|
|
16
|
+
constructor(currentRevision: number);
|
|
17
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type { ActionReceipt, ActionReceiptOutcome, CreateUiInstanceInput, JsonObject, JsonPrimitive, JsonValue, UiActionHandlerContext, UiActionHandlerRegistration, UiActionHandlerResult, UiActionEnvelope, UiActor, UiDefinition, UiDefinitionAction, UiDefinitionInput, UiDefinitionRef, UiProjectionPolicy, UiExecutionContext, UiAuthenticatedActor, UiAuthenticatedExecutionContext, UiAuthenticatedGrantPolicy, UiServerRuntimeFacade, UiServerRuntimeOptions, UiAgentContextProjection, UiExternalActionHandlerRegistration, UiInstance, UiInstanceStatus, UiLocalGrantPolicy, UiRuntimeFacade, UiRuntimeOptions, UiStateActionHandlerRegistration, } from './types.js';
|
|
2
|
+
export { resolveUiEffectiveCapabilities } from './types.js';
|
|
3
|
+
export { UiRuntimeError } from './errors.js';
|
|
4
|
+
export type { UiRuntimeErrorCode } from './errors.js';
|
|
5
|
+
export { hashUiDefinition } from './definition.js';
|
|
6
|
+
export { createUiRuntimeForTest, createUiServerRuntime } from './runtime.js';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { JsonObject, JsonValue } from './types.js';
|
|
2
|
+
export declare function projectSafeJsonObject(value: unknown): JsonObject;
|
|
3
|
+
export declare function serializeJson(value: JsonValue): string;
|
|
4
|
+
export declare function canonicalJson(value: JsonValue): string;
|
|
5
|
+
export declare function utf8ByteLength(value: string): number;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { UiRuntimeFacade, UiRuntimeOptions, UiServerRuntimeFacade, UiServerRuntimeOptions } from './types.js';
|
|
2
|
+
export interface UiRuntimeTestHooks {
|
|
3
|
+
beforeReservation?: () => Promise<void> | void;
|
|
4
|
+
injectDatabaseError?: () => unknown | undefined;
|
|
5
|
+
bumpRevisionBeforeCas?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export interface UiRuntimeForTestOptions extends UiRuntimeOptions {
|
|
8
|
+
workspaceId: string;
|
|
9
|
+
testHooks?: UiRuntimeTestHooks;
|
|
10
|
+
}
|
|
11
|
+
export declare function createUiRuntime(workspaceId: string, options: UiRuntimeOptions): UiRuntimeFacade;
|
|
12
|
+
export declare function createUiRuntimeForTest(options: UiRuntimeForTestOptions): UiRuntimeFacade;
|
|
13
|
+
export declare function createUiServerRuntime(options: UiServerRuntimeOptions): UiServerRuntimeFacade;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { ActionReceipt, ActionReceiptOutcome, JsonObject, UiActionHandlerContext, UiActor, UiInstance } from './types.js';
|
|
2
|
+
interface UiInstanceStoreTestHooks {
|
|
3
|
+
injectDatabaseError?: () => unknown | undefined;
|
|
4
|
+
bumpRevisionBeforeCas?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export interface ReservationInput {
|
|
7
|
+
instanceId: string;
|
|
8
|
+
requestId: string;
|
|
9
|
+
actionId: string;
|
|
10
|
+
actor: UiActor;
|
|
11
|
+
source: 'cli' | 'ui_host' | 'system';
|
|
12
|
+
expectedRevision: number;
|
|
13
|
+
input: JsonObject;
|
|
14
|
+
now: number;
|
|
15
|
+
}
|
|
16
|
+
export interface StateHandlerExecution {
|
|
17
|
+
handle: (context: UiActionHandlerContext) => {
|
|
18
|
+
state?: JsonObject;
|
|
19
|
+
result?: JsonObject;
|
|
20
|
+
} | {
|
|
21
|
+
outcome: 'rejected' | 'failed';
|
|
22
|
+
errorCode: string;
|
|
23
|
+
state?: JsonObject;
|
|
24
|
+
result?: JsonObject;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
export interface ExternalReservation {
|
|
28
|
+
instance: UiInstance;
|
|
29
|
+
receipt: ActionReceipt;
|
|
30
|
+
reservedRevision: number;
|
|
31
|
+
}
|
|
32
|
+
export declare class UiInstanceStore {
|
|
33
|
+
private readonly handle;
|
|
34
|
+
private readonly db;
|
|
35
|
+
private readonly testHooks?;
|
|
36
|
+
constructor(dbPath?: string, testHooks?: UiInstanceStoreTestHooks);
|
|
37
|
+
close(): void;
|
|
38
|
+
create(input: {
|
|
39
|
+
id: string;
|
|
40
|
+
definitionId: string;
|
|
41
|
+
definitionVersion: number;
|
|
42
|
+
definitionHash: string;
|
|
43
|
+
workspaceId: string;
|
|
44
|
+
threadId: string;
|
|
45
|
+
anchorTaskId: string | null;
|
|
46
|
+
domainRef: JsonObject;
|
|
47
|
+
state: JsonObject;
|
|
48
|
+
grants: readonly string[];
|
|
49
|
+
now: number;
|
|
50
|
+
}): UiInstance;
|
|
51
|
+
get(instanceId: string): UiInstance | null;
|
|
52
|
+
getReceipt(instanceId: string, requestId: string): ActionReceipt | null;
|
|
53
|
+
runStateOnly(reservation: ReservationInput, handler: StateHandlerExecution['handle']): ActionReceipt;
|
|
54
|
+
reserveExternal(reservation: ReservationInput): ExternalReservation;
|
|
55
|
+
settleExternal(input: {
|
|
56
|
+
reservation: ReservationInput;
|
|
57
|
+
reservedRevision: number;
|
|
58
|
+
outcome: ActionReceiptOutcome;
|
|
59
|
+
state: JsonObject;
|
|
60
|
+
result: JsonObject | null;
|
|
61
|
+
errorCode: string | null;
|
|
62
|
+
now: number;
|
|
63
|
+
}): ActionReceipt;
|
|
64
|
+
}
|
|
65
|
+
export {};
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
export type JsonPrimitive = string | number | boolean | null;
|
|
2
|
+
export type JsonValue = JsonPrimitive | JsonObject | JsonValue[];
|
|
3
|
+
export interface JsonObject {
|
|
4
|
+
[key: string]: JsonValue;
|
|
5
|
+
}
|
|
6
|
+
export type UiInstanceStatus = 'active' | 'completed' | 'expired' | 'revoked' | 'unsupported';
|
|
7
|
+
export interface UiDefinitionRef {
|
|
8
|
+
id: string;
|
|
9
|
+
version: number;
|
|
10
|
+
hash: string;
|
|
11
|
+
}
|
|
12
|
+
export interface UiDefinitionAction {
|
|
13
|
+
readonly capabilities: readonly string[];
|
|
14
|
+
readonly inputKeys?: readonly string[];
|
|
15
|
+
readonly resultProjection?: UiProjectionPolicy;
|
|
16
|
+
}
|
|
17
|
+
export interface UiProjectionPolicy {
|
|
18
|
+
allow: readonly string[];
|
|
19
|
+
}
|
|
20
|
+
export interface UiDefinitionInput {
|
|
21
|
+
readonly id: string;
|
|
22
|
+
readonly version: number;
|
|
23
|
+
readonly actions: Readonly<Record<string, UiDefinitionAction>>;
|
|
24
|
+
readonly renderer?: string;
|
|
25
|
+
readonly surfaces?: readonly string[];
|
|
26
|
+
readonly stateProjection?: UiProjectionPolicy;
|
|
27
|
+
}
|
|
28
|
+
export interface UiDefinition extends UiDefinitionInput {
|
|
29
|
+
readonly hash: string;
|
|
30
|
+
}
|
|
31
|
+
export interface CreateUiInstanceInput {
|
|
32
|
+
definition: UiDefinitionRef;
|
|
33
|
+
workspaceId: string;
|
|
34
|
+
threadId: string;
|
|
35
|
+
anchorTaskId?: string;
|
|
36
|
+
domainRef: JsonObject;
|
|
37
|
+
state: JsonObject;
|
|
38
|
+
}
|
|
39
|
+
export interface UiInstance {
|
|
40
|
+
id: string;
|
|
41
|
+
definition: UiDefinitionRef;
|
|
42
|
+
workspaceId: string;
|
|
43
|
+
threadId: string;
|
|
44
|
+
anchorTaskId: string | null;
|
|
45
|
+
domainRef: JsonObject;
|
|
46
|
+
state: JsonObject;
|
|
47
|
+
revision: number;
|
|
48
|
+
status: UiInstanceStatus;
|
|
49
|
+
grantedCapabilities: readonly string[];
|
|
50
|
+
createdAt: number;
|
|
51
|
+
updatedAt: number;
|
|
52
|
+
}
|
|
53
|
+
export interface UiActionEnvelope {
|
|
54
|
+
instanceId: string;
|
|
55
|
+
actionId: string;
|
|
56
|
+
expectedRevision: number;
|
|
57
|
+
requestId: string;
|
|
58
|
+
input: JsonObject;
|
|
59
|
+
}
|
|
60
|
+
export type UiActor = {
|
|
61
|
+
kind: 'local';
|
|
62
|
+
id: string;
|
|
63
|
+
} | {
|
|
64
|
+
kind: 'authenticated';
|
|
65
|
+
id: string;
|
|
66
|
+
};
|
|
67
|
+
export interface UiExecutionContext {
|
|
68
|
+
source: 'cli' | 'ui_host' | 'system';
|
|
69
|
+
workspaceId: string;
|
|
70
|
+
actor: UiActor;
|
|
71
|
+
}
|
|
72
|
+
export interface UiAuthenticatedActor {
|
|
73
|
+
kind: 'authenticated';
|
|
74
|
+
id: string;
|
|
75
|
+
}
|
|
76
|
+
export interface UiAuthenticatedExecutionContext {
|
|
77
|
+
source: 'ui_host' | 'system';
|
|
78
|
+
workspaceId: string;
|
|
79
|
+
threadId: string;
|
|
80
|
+
actor: UiAuthenticatedActor;
|
|
81
|
+
}
|
|
82
|
+
export type ActionReceiptOutcome = 'succeeded' | 'rejected' | 'failed' | 'conflicted' | 'expired';
|
|
83
|
+
export interface ActionReceipt {
|
|
84
|
+
id: string;
|
|
85
|
+
instanceId: string;
|
|
86
|
+
requestId: string;
|
|
87
|
+
actionId: string;
|
|
88
|
+
actor: UiActor;
|
|
89
|
+
source: 'cli' | 'ui_host' | 'system';
|
|
90
|
+
expectedRevision: number;
|
|
91
|
+
beforeRevision: number;
|
|
92
|
+
afterRevision: number | null;
|
|
93
|
+
status: 'requested' | 'settled';
|
|
94
|
+
outcome: ActionReceiptOutcome | null;
|
|
95
|
+
input: JsonObject;
|
|
96
|
+
result: JsonObject | null;
|
|
97
|
+
errorCode: string | null;
|
|
98
|
+
requestedAt: number;
|
|
99
|
+
settledAt: number | null;
|
|
100
|
+
}
|
|
101
|
+
export interface UiLocalGrantPolicy {
|
|
102
|
+
resolveInstanceGrants(input: {
|
|
103
|
+
definition: UiDefinitionRef;
|
|
104
|
+
workspaceId: string;
|
|
105
|
+
actor: Extract<UiActor, {
|
|
106
|
+
kind: 'local';
|
|
107
|
+
}>;
|
|
108
|
+
}): readonly string[];
|
|
109
|
+
resolveActionCapabilities(input: {
|
|
110
|
+
definition: UiDefinitionRef;
|
|
111
|
+
actionId: string;
|
|
112
|
+
}): readonly string[];
|
|
113
|
+
}
|
|
114
|
+
export interface UiActionHandlerContext {
|
|
115
|
+
instance: UiInstance;
|
|
116
|
+
actor: UiActor;
|
|
117
|
+
source: 'cli' | 'ui_host' | 'system';
|
|
118
|
+
input: JsonObject;
|
|
119
|
+
requestId: string;
|
|
120
|
+
}
|
|
121
|
+
export type UiActionHandlerResult = {
|
|
122
|
+
state?: JsonObject;
|
|
123
|
+
result?: JsonObject;
|
|
124
|
+
} | {
|
|
125
|
+
outcome: 'rejected' | 'failed';
|
|
126
|
+
errorCode: string;
|
|
127
|
+
state?: JsonObject;
|
|
128
|
+
result?: JsonObject;
|
|
129
|
+
};
|
|
130
|
+
export interface UiStateActionHandlerRegistration {
|
|
131
|
+
definitionId: string;
|
|
132
|
+
version: number;
|
|
133
|
+
actionId: string;
|
|
134
|
+
kind: 'state';
|
|
135
|
+
handle: (context: UiActionHandlerContext) => UiActionHandlerResult;
|
|
136
|
+
}
|
|
137
|
+
export interface UiExternalActionHandlerRegistration {
|
|
138
|
+
definitionId: string;
|
|
139
|
+
version: number;
|
|
140
|
+
actionId: string;
|
|
141
|
+
kind: 'external';
|
|
142
|
+
handle: (context: UiActionHandlerContext) => Promise<UiActionHandlerResult>;
|
|
143
|
+
}
|
|
144
|
+
export type UiActionHandlerRegistration = UiStateActionHandlerRegistration | UiExternalActionHandlerRegistration;
|
|
145
|
+
export interface UiRuntimeOptions {
|
|
146
|
+
dbPath?: string;
|
|
147
|
+
localActor: Extract<UiActor, {
|
|
148
|
+
kind: 'local';
|
|
149
|
+
}>;
|
|
150
|
+
localGrantPolicy?: UiLocalGrantPolicy;
|
|
151
|
+
definitions?: readonly UiDefinition[];
|
|
152
|
+
handlers?: readonly UiActionHandlerRegistration[];
|
|
153
|
+
clock?: () => number;
|
|
154
|
+
}
|
|
155
|
+
export interface UiRuntimeFacade {
|
|
156
|
+
resolveDefinition(ref: UiDefinitionRef): UiDefinition | null;
|
|
157
|
+
createInstance(input: CreateUiInstanceInput): Promise<UiInstance>;
|
|
158
|
+
dispatchAction(input: UiActionEnvelope, context: UiExecutionContext): Promise<ActionReceipt>;
|
|
159
|
+
getReceipt(instanceId: string, requestId: string): Promise<ActionReceipt | null>;
|
|
160
|
+
close(): void;
|
|
161
|
+
}
|
|
162
|
+
export interface UiAuthenticatedGrantPolicy {
|
|
163
|
+
resolveInstanceGrants(input: {
|
|
164
|
+
definition: UiDefinitionRef;
|
|
165
|
+
workspaceId: string;
|
|
166
|
+
actor: UiAuthenticatedActor;
|
|
167
|
+
}): readonly string[];
|
|
168
|
+
resolveDispatchCapabilities?(input: {
|
|
169
|
+
definition: UiDefinitionRef;
|
|
170
|
+
actionId: string;
|
|
171
|
+
actor: UiAuthenticatedActor;
|
|
172
|
+
source: 'ui_host' | 'system';
|
|
173
|
+
}): readonly string[];
|
|
174
|
+
}
|
|
175
|
+
export declare function resolveUiEffectiveCapabilities(declared: readonly string[], instanceGranted: readonly string[], dispatchGranted?: readonly string[]): readonly string[];
|
|
176
|
+
export interface UiServerRuntimeOptions {
|
|
177
|
+
workspaceId: string;
|
|
178
|
+
dbPath: string;
|
|
179
|
+
definitions: readonly UiDefinition[];
|
|
180
|
+
handlers: readonly UiActionHandlerRegistration[];
|
|
181
|
+
grantPolicy: UiAuthenticatedGrantPolicy;
|
|
182
|
+
clock?: () => number;
|
|
183
|
+
}
|
|
184
|
+
export interface UiServerRuntimeFacade {
|
|
185
|
+
resolveDefinition(ref: UiDefinitionRef): UiDefinition | null;
|
|
186
|
+
getInstance(instanceId: string, context: UiAuthenticatedExecutionContext): Promise<UiInstance | null>;
|
|
187
|
+
createInstance(input: CreateUiInstanceInput, context: UiAuthenticatedExecutionContext): Promise<UiInstance>;
|
|
188
|
+
dispatchAction(input: UiActionEnvelope, context: UiAuthenticatedExecutionContext): Promise<ActionReceipt>;
|
|
189
|
+
getReceipt(instanceId: string, requestId: string, context: UiAuthenticatedExecutionContext): Promise<ActionReceipt | null>;
|
|
190
|
+
close(): void;
|
|
191
|
+
}
|
|
192
|
+
export interface UiAgentContextProjection {
|
|
193
|
+
instanceId: string;
|
|
194
|
+
definition: UiDefinitionRef;
|
|
195
|
+
revision: number;
|
|
196
|
+
facts: JsonObject;
|
|
197
|
+
recentChanges: readonly JsonObject[];
|
|
198
|
+
pendingDecision: JsonObject | null;
|
|
199
|
+
availableActions: readonly string[];
|
|
200
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { canonicalManifestJson, manifestHash } from './manifest.js';
|
|
2
|
+
export { UiPluginValidationError, normalizeManifest, validateManifest, validatePayload, } from './validator.js';
|
|
3
|
+
export type { UiPluginActivation, UiPluginCardShellNode, UiPluginFieldSchema, UiPluginHeadingNode, UiPluginLabeledTextNode, UiPluginLayoutNode, UiPluginLayout, UiPluginManifest, UiPluginMetaBannerNode, UiPluginPayload, UiPluginPayloadValue, UiPluginPrimitive, UiPluginSchemaType, UiPluginSchema, UiPluginStep, UiPluginStepFlowNode, UiPluginStepListSchema, UiPluginTextListNode, UiPluginTextListSchema, UiPluginTextSchema, UiPluginValidationErrorCode, UiPluginValidationOptions, } from './types.js';
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
export type UiPluginPrimitive = 'card-shell' | 'meta-banner' | 'heading' | 'labeled-text' | 'step-flow' | 'text-list';
|
|
2
|
+
export type UiPluginSchemaType = 'text' | 'text-list' | 'step-list';
|
|
3
|
+
export interface UiPluginTextSchema {
|
|
4
|
+
readonly type: 'text';
|
|
5
|
+
readonly maxLength: number;
|
|
6
|
+
}
|
|
7
|
+
export interface UiPluginTextListSchema {
|
|
8
|
+
readonly type: 'text-list';
|
|
9
|
+
readonly max: number;
|
|
10
|
+
readonly itemMaxLength: number;
|
|
11
|
+
}
|
|
12
|
+
export interface UiPluginStepListSchema {
|
|
13
|
+
readonly type: 'step-list';
|
|
14
|
+
readonly min: number;
|
|
15
|
+
readonly max: number;
|
|
16
|
+
readonly labelMaxLength: number;
|
|
17
|
+
readonly detailMaxLength: number;
|
|
18
|
+
}
|
|
19
|
+
export type UiPluginFieldSchema = UiPluginTextSchema | UiPluginTextListSchema | UiPluginStepListSchema;
|
|
20
|
+
export type UiPluginSchema = Readonly<Record<string, UiPluginFieldSchema>>;
|
|
21
|
+
export interface UiPluginActivation {
|
|
22
|
+
readonly kind: 'fenced-code';
|
|
23
|
+
readonly language: string;
|
|
24
|
+
}
|
|
25
|
+
export interface UiPluginCardShellNode {
|
|
26
|
+
readonly primitive: 'card-shell';
|
|
27
|
+
}
|
|
28
|
+
export interface UiPluginMetaBannerNode {
|
|
29
|
+
readonly primitive: 'meta-banner';
|
|
30
|
+
readonly badgeToken: string;
|
|
31
|
+
readonly noticeToken: string;
|
|
32
|
+
}
|
|
33
|
+
export interface UiPluginHeadingNode {
|
|
34
|
+
readonly primitive: 'heading';
|
|
35
|
+
readonly field: string;
|
|
36
|
+
}
|
|
37
|
+
export interface UiPluginLabeledTextNode {
|
|
38
|
+
readonly primitive: 'labeled-text';
|
|
39
|
+
readonly titleToken: string;
|
|
40
|
+
readonly field: string;
|
|
41
|
+
readonly variant: 'callout';
|
|
42
|
+
}
|
|
43
|
+
export interface UiPluginStepFlowNode {
|
|
44
|
+
readonly primitive: 'step-flow';
|
|
45
|
+
readonly titleToken: string;
|
|
46
|
+
readonly field: string;
|
|
47
|
+
}
|
|
48
|
+
export interface UiPluginTextListNode {
|
|
49
|
+
readonly primitive: 'text-list';
|
|
50
|
+
readonly titleToken: string;
|
|
51
|
+
readonly field: string;
|
|
52
|
+
readonly emptyToken?: string;
|
|
53
|
+
readonly hideWhenEmpty?: boolean;
|
|
54
|
+
}
|
|
55
|
+
export type UiPluginLayoutNode = UiPluginCardShellNode | UiPluginMetaBannerNode | UiPluginHeadingNode | UiPluginLabeledTextNode | UiPluginStepFlowNode | UiPluginTextListNode;
|
|
56
|
+
export type UiPluginLayout = readonly UiPluginLayoutNode[];
|
|
57
|
+
export interface UiPluginManifest {
|
|
58
|
+
readonly manifestVersion: 1;
|
|
59
|
+
readonly pluginId: string;
|
|
60
|
+
readonly definitionId: string;
|
|
61
|
+
readonly version: number;
|
|
62
|
+
readonly primitiveSet: number;
|
|
63
|
+
readonly activation: UiPluginActivation;
|
|
64
|
+
readonly schema: UiPluginSchema;
|
|
65
|
+
readonly layout: UiPluginLayout;
|
|
66
|
+
}
|
|
67
|
+
export interface UiPluginStep {
|
|
68
|
+
readonly label: string;
|
|
69
|
+
readonly detail: string;
|
|
70
|
+
}
|
|
71
|
+
export type UiPluginPayloadValue = string | string[] | UiPluginStep[];
|
|
72
|
+
export type UiPluginPayload = Record<string, UiPluginPayloadValue>;
|
|
73
|
+
export interface UiPluginValidationOptions {
|
|
74
|
+
readonly supportedPrimitiveSet?: number;
|
|
75
|
+
}
|
|
76
|
+
export type UiPluginValidationErrorCode = 'MANIFEST_INVALID' | 'PRIMITIVE_UNKNOWN' | 'PRIMITIVE_SET_UNSUPPORTED' | 'SCHEMA_TYPE_UNSUPPORTED' | 'TOKEN_INVALID' | 'UNSAFE_VALUE';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { UiPluginManifest, UiPluginPayload, UiPluginValidationErrorCode, UiPluginValidationOptions } from './types.js';
|
|
2
|
+
export declare class UiPluginValidationError extends Error {
|
|
3
|
+
readonly code: UiPluginValidationErrorCode;
|
|
4
|
+
readonly name = "UiPluginValidationError";
|
|
5
|
+
constructor(code: UiPluginValidationErrorCode, message?: string);
|
|
6
|
+
}
|
|
7
|
+
export declare function validateManifest(input: unknown, options?: UiPluginValidationOptions): UiPluginManifest;
|
|
8
|
+
export declare function normalizeManifest(input: unknown, options?: UiPluginValidationOptions): UiPluginManifest;
|
|
9
|
+
export declare function validatePayload(manifest: UiPluginManifest, rawPayload: unknown): UiPluginPayload;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getCrewxHome(): string;
|
package/dist/utils/id.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type EntityPrefix = 'tsk' | 'thd' | 'msg' | 'box' | 'prj' | 'mem' | 'spn' | 'cron' | 'wbs' | 'job' | 'tcl' | 'req' | 'ws' | 'wfr';
|
|
1
|
+
export type EntityPrefix = 'tsk' | 'thd' | 'msg' | 'box' | 'prj' | 'mem' | 'spn' | 'cron' | 'wbs' | 'job' | 'tcl' | 'req' | 'ws' | 'wfr' | 'ntf' | 'sug' | 'brd' | 'pjc' | 'pje' | 'the' | 'thl' | 'thr';
|
|
2
2
|
export type PrefixedId<P extends EntityPrefix> = `${P}_${string}`;
|
|
3
3
|
export declare function generateId<P extends EntityPrefix>(prefix: P): PrefixedId<P>;
|
|
4
4
|
export declare function generateFingerprint<P extends EntityPrefix>(prefix: P, input: string): PrefixedId<P>;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export type WiStatus = 'draft' | 'approved' | 'in-progress' | 'done' | 'cancelled';
|
|
2
|
+
export interface WiCreateInput {
|
|
3
|
+
title: string;
|
|
4
|
+
assignee?: string;
|
|
5
|
+
body?: string;
|
|
6
|
+
board?: string;
|
|
7
|
+
source?: string;
|
|
8
|
+
depends_on?: string[];
|
|
9
|
+
}
|
|
10
|
+
export interface WiBatchCreateInput {
|
|
11
|
+
board: string;
|
|
12
|
+
source?: string;
|
|
13
|
+
items: Array<{
|
|
14
|
+
key?: string;
|
|
15
|
+
title: string;
|
|
16
|
+
assignee?: string;
|
|
17
|
+
depends_on?: string[];
|
|
18
|
+
body: string;
|
|
19
|
+
}>;
|
|
20
|
+
}
|
|
21
|
+
export interface WiCreatedSummary {
|
|
22
|
+
wi_id: string;
|
|
23
|
+
title: string;
|
|
24
|
+
status: WiStatus;
|
|
25
|
+
priority?: string;
|
|
26
|
+
assignee?: string;
|
|
27
|
+
depends_on: string[];
|
|
28
|
+
blocks: string[];
|
|
29
|
+
date?: string;
|
|
30
|
+
board?: string;
|
|
31
|
+
source: string;
|
|
32
|
+
screens: string[];
|
|
33
|
+
path: string;
|
|
34
|
+
mtime: number;
|
|
35
|
+
}
|
|
36
|
+
export interface WiCreatedDetail {
|
|
37
|
+
summary: WiCreatedSummary;
|
|
38
|
+
frontmatter: Record<string, unknown>;
|
|
39
|
+
body: string;
|
|
40
|
+
}
|
|
41
|
+
export interface WiBatchCreateResult {
|
|
42
|
+
created: WiCreatedDetail[];
|
|
43
|
+
}
|
|
44
|
+
export declare class WiCreateError extends Error {
|
|
45
|
+
constructor(message: string);
|
|
46
|
+
}
|
|
47
|
+
export declare function createWorkInstruction(workspacePath: string, input: WiCreateInput): Promise<WiCreatedDetail>;
|
|
48
|
+
export declare function createWorkInstructionBatch(workspacePath: string, input: WiBatchCreateInput): Promise<WiBatchCreateResult>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export type WiSelectableStatus = 'draft' | 'approved' | 'in-progress' | 'done' | 'cancelled';
|
|
2
|
+
export interface WiSummary {
|
|
3
|
+
wi_id: string;
|
|
4
|
+
status: WiSelectableStatus;
|
|
5
|
+
depends_on?: string[];
|
|
6
|
+
}
|
|
7
|
+
export type SelectNextWiResult = {
|
|
8
|
+
pick: string;
|
|
9
|
+
} | {
|
|
10
|
+
blocked: true;
|
|
11
|
+
reason: string;
|
|
12
|
+
} | {
|
|
13
|
+
cycle: string[];
|
|
14
|
+
} | {
|
|
15
|
+
done: true;
|
|
16
|
+
};
|
|
17
|
+
export declare function selectNextWi(wis: WiSummary[], opts: {
|
|
18
|
+
batch: string[];
|
|
19
|
+
exclude?: string[];
|
|
20
|
+
}): SelectNextWiResult;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crewx/sdk",
|
|
3
|
-
"version": "0.9.0-rc.
|
|
3
|
+
"version": "0.9.0-rc.80",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=20.19.0"
|
|
@@ -50,6 +50,16 @@
|
|
|
50
50
|
"import": "./dist/repository/index.js",
|
|
51
51
|
"require": "./dist/repository/index.js"
|
|
52
52
|
},
|
|
53
|
+
"./desktop": {
|
|
54
|
+
"types": "./dist/desktop/index.d.ts",
|
|
55
|
+
"import": "./dist/desktop/index.js",
|
|
56
|
+
"require": "./dist/desktop/index.js"
|
|
57
|
+
},
|
|
58
|
+
"./publish": {
|
|
59
|
+
"types": "./dist/publish/index.d.ts",
|
|
60
|
+
"import": "./dist/publish/index.js",
|
|
61
|
+
"require": "./dist/publish/index.js"
|
|
62
|
+
},
|
|
53
63
|
"./package.json": "./package.json"
|
|
54
64
|
},
|
|
55
65
|
"browser": {
|
|
@@ -60,7 +70,11 @@
|
|
|
60
70
|
"./dist/layout/loader.js": false,
|
|
61
71
|
"./dist/esm/layout/loader.js": false,
|
|
62
72
|
"./dist/repository/index.js": false,
|
|
63
|
-
"./dist/esm/repository/index.js": false
|
|
73
|
+
"./dist/esm/repository/index.js": false,
|
|
74
|
+
"./dist/desktop/index.js": false,
|
|
75
|
+
"./dist/esm/desktop/index.js": false,
|
|
76
|
+
"./dist/publish/index.js": false,
|
|
77
|
+
"./dist/esm/publish/index.js": false
|
|
64
78
|
},
|
|
65
79
|
"files": [
|
|
66
80
|
"dist",
|
|
@@ -74,7 +88,9 @@
|
|
|
74
88
|
"ai": "4.0.0",
|
|
75
89
|
"drizzle-orm": "0.45.2",
|
|
76
90
|
"handlebars": "4.7.9",
|
|
91
|
+
"js-tiktoken": "1.0.21",
|
|
77
92
|
"js-yaml": "4.1.0",
|
|
93
|
+
"tar": "7.5.15",
|
|
78
94
|
"zod": "3.25.76"
|
|
79
95
|
},
|
|
80
96
|
"peerDependencies": {
|