@crewx/sdk 0.9.0-rc.14 → 0.9.0-rc.140
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/account/auth-client.d.ts +61 -0
- package/dist/account/auth-json-v2.d.ts +1 -0
- package/dist/account/auth-json.d.ts +30 -0
- package/dist/account/config.d.ts +37 -0
- package/dist/account/env-bootstrap.d.ts +11 -0
- package/dist/account/errors.d.ts +24 -0
- package/dist/account/index.d.ts +12 -0
- package/dist/account/index.js +2 -0
- package/dist/account/session-manager.d.ts +47 -0
- package/dist/activity-log/builder.d.ts +59 -6
- package/dist/agent/agent-list-view.d.ts +19 -0
- package/dist/app/app.d.ts +100 -0
- package/dist/app/backend-env.d.ts +3 -0
- package/dist/app/entry.d.ts +7 -0
- package/dist/app/index.d.ts +8 -0
- package/dist/app/index.js +9 -0
- package/dist/app/runtime.d.ts +19 -0
- package/dist/boxing/box.types.d.ts +4 -0
- package/dist/config/canonicalize-agent-options.d.ts +18 -0
- package/dist/config/default-agent-models.d.ts +11 -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 +37 -0
- package/dist/config/models.remote.d.ts +1 -0
- package/dist/config/overdrive.d.ts +7 -0
- package/dist/config/pricing.d.ts +6 -3
- package/dist/config/pricing.generated.d.ts +4 -0
- package/dist/config/pricing.types.d.ts +4 -0
- package/dist/config/timeout.config.d.ts +4 -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 +141 -0
- package/dist/conversation/index.d.ts +1 -1
- package/dist/conversation/sqlite-provider.d.ts +6 -3
- package/dist/conversation/to-template-messages.d.ts +9 -0
- package/dist/conversation/types.d.ts +48 -1
- 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 +3 -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/account/index.js +2 -0
- package/dist/esm/app/index.js +9 -0
- package/dist/esm/desktop/index.js +3 -0
- package/dist/esm/index.js +1069 -224
- package/dist/esm/node/index.js +2 -0
- package/dist/esm/plugins/index.js +474 -216
- package/dist/esm/process/index.js +1 -0
- package/dist/esm/publish/index.js +2 -0
- package/dist/esm/repository/index.js +586 -213
- package/dist/esm/skills/index.js +2 -0
- package/dist/esm/testing/index.js +1 -1
- package/dist/events/types.d.ts +9 -0
- package/dist/facade/Crewx.d.ts +60 -5
- package/dist/facade/task-ticket.d.ts +14 -0
- 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 +17 -1
- package/dist/index.browser.js +6 -2
- package/dist/index.d.ts +124 -17
- package/dist/index.js +1069 -224
- package/dist/internal/console-decoder.d.ts +38 -0
- package/dist/internal/windows-spawn.d.ts +10 -0
- package/dist/layout/types.d.ts +18 -1
- package/dist/lifecycle/process-lease.d.ts +80 -0
- package/dist/lifecycle/process-owner.d.ts +20 -0
- package/dist/lifecycle/task-heartbeat.d.ts +41 -0
- package/dist/lifecycle/task-stop.d.ts +82 -0
- package/dist/lifecycle/update-admission.d.ts +45 -0
- 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/mcp-app/agent-access.d.ts +26 -0
- package/dist/mcp-app/apps-context.d.ts +20 -0
- package/dist/mcp-app/bundle-provenance.d.ts +3 -0
- package/dist/mcp-app/catalog.d.ts +7 -0
- package/dist/mcp-app/content-channel.d.ts +89 -0
- package/dist/mcp-app/content-declarations.d.ts +29 -0
- package/dist/mcp-app/dev-checks.d.ts +29 -0
- package/dist/mcp-app/diagnostic-reason.d.ts +3 -0
- package/dist/mcp-app/discovery.d.ts +160 -0
- package/dist/mcp-app/errors.d.ts +7 -0
- package/dist/mcp-app/index.d.ts +33 -0
- package/dist/mcp-app/installed-app-ref.d.ts +25 -0
- package/dist/mcp-app/model-context.d.ts +29 -0
- package/dist/mcp-app/node-app-discovery-fs.d.ts +23 -0
- package/dist/mcp-app/product-bundle-assets.d.ts +27 -0
- package/dist/mcp-app/product-bundle-loader.d.ts +53 -0
- package/dist/mcp-app/projection.d.ts +14 -0
- package/dist/mcp-app/registry.d.ts +28 -0
- package/dist/mcp-app/skill-backend.d.ts +133 -0
- package/dist/mcp-app/state-set.d.ts +9 -0
- package/dist/mcp-app/types.d.ts +472 -0
- package/dist/mcp-app/workspace-app-assets.d.ts +42 -0
- package/dist/mcp-app/workspace-app-scan-cache.d.ts +24 -0
- package/dist/mcp-app/workspace-snapshot.d.ts +71 -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/0022_wandering_bucky.sql +1 -0
- package/dist/migrations/0023_red_payback.sql +1 -0
- package/dist/migrations/0024_storage_metadata.sql +262 -0
- package/dist/migrations/0025_task_heartbeat.sql +8 -0
- package/dist/migrations/0025_thread_app_instance_ledger.sql +2 -0
- package/dist/migrations/0026_mcp_action_source.sql +47 -0
- package/dist/migrations/0027_task_stop_scope_cleanup.sql +5 -0
- package/dist/migrations/0027_ui_instance_active_unique.sql +2 -0
- package/dist/migrations/0029_nice_rhino.sql +1 -0
- package/dist/migrations/0031_petite_arclight.sql +6 -0
- package/dist/migrations/0032_ui_instance_opened_by.sql +1 -0
- package/dist/migrations/0033_thread_creator_boundary_guard.sql +38 -0
- package/dist/migrations/0034_keen_fallen_one.sql +36 -0
- package/dist/migrations/0035_request_log_daily.sql +11 -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/0022_snapshot.json +3039 -0
- package/dist/migrations/meta/0023_snapshot.json +3047 -0
- package/dist/migrations/meta/0029_snapshot.json +3206 -0
- package/dist/migrations/meta/0031_snapshot.json +3251 -0
- package/dist/migrations/meta/0034_snapshot.json +3473 -0
- package/dist/migrations/meta/0035_snapshot.json +3547 -0
- package/dist/migrations/meta/_journal.json +175 -0
- package/dist/node/index.d.ts +1 -0
- package/dist/node/index.js +2 -0
- package/dist/paths.d.ts +1 -0
- package/dist/plugin/types.d.ts +1 -0
- package/dist/plugins/index.d.ts +1 -1
- package/dist/plugins/index.js +474 -216
- package/dist/plugins/sqlite-tracing.d.ts +46 -0
- package/dist/process/index.d.ts +2 -0
- package/dist/process/index.js +1 -0
- package/dist/process/process-control.d.ts +41 -0
- package/dist/prompt/tag-names.d.ts +22 -0
- package/dist/provider/acp/connection.d.ts +6 -0
- package/dist/provider/acp/meta.d.ts +11 -0
- package/dist/provider/bridge.d.ts +7 -1
- package/dist/provider/classify-task-error.d.ts +2 -0
- package/dist/provider/cli/adapter.types.d.ts +14 -2
- package/dist/provider/cli/adapters/agent-call.util.d.ts +1 -1
- package/dist/provider/cli/adapters/cli-knob.util.d.ts +7 -0
- package/dist/provider/cli/adapters/codex-item.d.ts +1 -0
- package/dist/provider/cli/adapters/event-timestamp.util.d.ts +1 -0
- package/dist/provider/cli/adapters/grok.d.ts +2 -0
- package/dist/provider/cli/adapters/index.d.ts +5 -0
- package/dist/provider/cli/index.d.ts +3 -2
- package/dist/provider/cli/meta.d.ts +5 -0
- package/dist/provider/cli/protocol-envelope.d.ts +3 -0
- package/dist/provider/errors.d.ts +5 -1
- 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 +17 -0
- package/dist/publish/constants.d.ts +6 -0
- package/dist/publish/errors.d.ts +7 -0
- package/dist/publish/index.d.ts +50 -0
- package/dist/publish/index.js +2 -0
- package/dist/publish/manifest.d.ts +47 -0
- package/dist/publish/marketplace-api.constants.d.ts +1 -0
- package/dist/publish/pack.d.ts +6 -0
- package/dist/publish/scan.d.ts +9 -0
- package/dist/publish/secrets.d.ts +6 -0
- package/dist/publish/upload.d.ts +19 -0
- package/dist/remote/execution-profile.d.ts +9 -0
- package/dist/remote/index.d.ts +1 -0
- package/dist/remote/types.d.ts +28 -0
- package/dist/repository/agent-suggestion.repository.d.ts +34 -0
- package/dist/repository/base-sqlite-repository.d.ts +1 -0
- package/dist/repository/common-code.repository.d.ts +45 -0
- package/dist/repository/db.d.ts +12 -1
- package/dist/repository/index.d.ts +41 -5
- package/dist/repository/index.js +586 -213
- package/dist/repository/logs-db.d.ts +12 -0
- package/dist/repository/notification.repository.d.ts +58 -0
- package/dist/repository/project.repository.d.ts +90 -0
- package/dist/repository/request-log-mover.d.ts +70 -0
- package/dist/repository/request-log.repository.d.ts +7 -3
- package/dist/repository/storage-metadata.repository.d.ts +64 -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-status.d.ts +21 -0
- package/dist/repository/task.repository.d.ts +229 -7
- package/dist/repository/thread-history.repository.d.ts +193 -0
- package/dist/repository/thread-origin-verdict.d.ts +27 -0
- package/dist/repository/thread-title.types.d.ts +29 -0
- package/dist/repository/thread.repository.d.ts +115 -7
- package/dist/repository/usage-backfill.d.ts +62 -0
- package/dist/repository/usage-from-logs.d.ts +21 -0
- package/dist/repository/workspace.repository.d.ts +3 -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 +12 -0
- package/dist/schema/notifications.d.ts +303 -0
- package/dist/schema/projects.d.ts +610 -0
- package/dist/schema/request-log-daily.d.ts +151 -0
- package/dist/schema/storage-metadata.d.ts +181 -0
- package/dist/schema/task-log-events.d.ts +119 -0
- package/dist/schema/tasks.d.ts +165 -0
- package/dist/schema/thread-creator-unverified.d.ts +45 -0
- package/dist/schema/thread-history.d.ts +734 -0
- package/dist/schema/threads.d.ts +59 -0
- package/dist/schema/ui-action-receipts.d.ts +358 -0
- package/dist/schema/ui-instance-repins.d.ts +222 -0
- package/dist/schema/ui-instances.d.ts +305 -0
- package/dist/schema/workspaces.d.ts +17 -0
- package/dist/skills/index.d.ts +15 -0
- package/dist/skills/index.js +2 -0
- package/dist/skills/types.d.ts +18 -0
- package/dist/task-log/anchor-child-tasks.d.ts +7 -0
- package/dist/task-log/delegation-trailer.d.ts +34 -0
- package/dist/template/engine.d.ts +2 -2
- package/dist/template/helpers/exec.browser.d.ts +4 -3
- package/dist/template/helpers/exec.d.ts +4 -3
- package/dist/template/types.d.ts +20 -0
- package/dist/testing/index.js +1 -1
- package/dist/types/index.d.ts +1574 -3
- package/dist/types/task-log.types.d.ts +3 -0
- 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 +18 -0
- package/dist/ui-instance/index.d.ts +11 -0
- package/dist/ui-instance/json.d.ts +19 -0
- package/dist/ui-instance/lineage.d.ts +22 -0
- package/dist/ui-instance/runtime.d.ts +18 -0
- package/dist/ui-instance/store.d.ts +184 -0
- package/dist/ui-instance/types.d.ts +319 -0
- package/dist/ui-plugin/app-manifest.d.ts +59 -0
- package/dist/ui-plugin/csp.d.ts +28 -0
- package/dist/ui-plugin/index.d.ts +6 -0
- package/dist/ui-plugin/limits.d.ts +27 -0
- package/dist/ui-plugin/manifest.d.ts +3 -0
- package/dist/ui-plugin/types.d.ts +194 -0
- package/dist/ui-plugin/validator.d.ts +18 -0
- package/dist/utils/crewx-executable.d.ts +76 -0
- package/dist/utils/crewx-home.d.ts +1 -0
- package/dist/utils/env-defaults.d.ts +3 -0
- package/dist/utils/id.d.ts +1 -1
- package/dist/utils/local-identity.d.ts +2 -0
- package/dist/utils/runner-env.d.ts +3 -0
- package/dist/utils/timestamp.d.ts +1 -0
- package/dist/utils/workspace.d.ts +1 -0
- package/dist/wi/create.d.ts +48 -0
- package/dist/wi/select.d.ts +20 -0
- package/package.json +57 -3
- package/templates/agents/default.yaml +296 -128
- package/templates/documents/crewx-manual.md +138 -138
- package/templates/documents/crewx-quick-guide.md +8 -7
- package/templates/workflows/wi-default-flow.yaml +65 -0
- package/templates/workflows/wi-plan-flow.yaml +140 -0
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { DelegationResult } from '../task-log/delegation-trailer.js';
|
|
1
2
|
export type TaskLogEntryType = 'text' | 'thinking' | 'tool_use' | 'tool_result' | 'error' | 'info' | 'running_instruction' | 'agent_call';
|
|
2
3
|
export interface TaskLogEntry {
|
|
3
4
|
timestamp: string;
|
|
@@ -5,9 +6,11 @@ export interface TaskLogEntry {
|
|
|
5
6
|
content?: string;
|
|
6
7
|
toolName?: string;
|
|
7
8
|
toolInput?: string;
|
|
9
|
+
toolTitle?: string;
|
|
8
10
|
toolUseId?: string;
|
|
9
11
|
resultPreview?: string;
|
|
10
12
|
isError?: boolean;
|
|
13
|
+
delegationResult?: DelegationResult | null;
|
|
11
14
|
targetAgent?: string;
|
|
12
15
|
targetTaskId?: string;
|
|
13
16
|
errorMessage?: string;
|
|
@@ -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,18 @@
|
|
|
1
|
+
import type { UiContentErrorCode } from '../mcp-app/content-channel.js';
|
|
2
|
+
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' | UiContentErrorCode;
|
|
3
|
+
export declare class UiRuntimeError extends Error {
|
|
4
|
+
readonly code: UiRuntimeErrorCode;
|
|
5
|
+
readonly currentRevision?: number | undefined;
|
|
6
|
+
readonly name = "UiRuntimeError";
|
|
7
|
+
constructor(code: UiRuntimeErrorCode, message?: string, currentRevision?: number | undefined);
|
|
8
|
+
}
|
|
9
|
+
export declare class UiRetryableDatabaseError extends Error {
|
|
10
|
+
readonly cause: unknown;
|
|
11
|
+
readonly name = "UiRetryableDatabaseError";
|
|
12
|
+
constructor(cause: unknown);
|
|
13
|
+
}
|
|
14
|
+
export declare class UiReservationConflictError extends Error {
|
|
15
|
+
readonly currentRevision: number;
|
|
16
|
+
readonly name = "UiReservationConflictError";
|
|
17
|
+
constructor(currentRevision: number);
|
|
18
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type { ActionReceipt, ActionReceiptResultSummary, ActionExecutionReceipt, ActionReceiptOutcome, CreateUiInstanceInput, JsonObject, JsonPrimitive, JsonValue, UiActionHandlerContext, UiActionHandlerRegistration, UiActionHandlerResult, UiActionEnvelope, UiActionConfirmation, UiSkillBackendEnvironmentKey, UiActor, UiDefinition, UiDefinitionAction, UiDefinitionDisplayMode, UiDefinitionInput, UiDefinitionLegacyMetadata, UiDefinitionRef, UiDefinitionUsage, UiProjectionPolicy, UiExecutionContext, UiAuthenticatedActor, UiTaskActorSnapshot, UiAuthenticatedExecutionContext, UiApprovalRequestContext, UiTaskExecutionContext, UiApprovalDecisionProvenance, UiApprovalPendingReceipt, UiApprovalRequestReceiptResult, UiAuthenticatedGrantPolicy, UiServerRuntimeFacade, UiServerRuntimeOptions, UiAgentContextProjection, UiExternalActionHandlerRegistration, UiInstance, UiInstanceStatus, UiLocalGrantPolicy, UiRuntimeFacade, UiRuntimeOptions, UiStateActionHandlerRegistration, } from './types.js';
|
|
2
|
+
export { isUiAuthenticatedActor, resolveUiEffectiveCapabilities } from './types.js';
|
|
3
|
+
export { UiRuntimeError } from './errors.js';
|
|
4
|
+
export type { UiRuntimeErrorCode } from './errors.js';
|
|
5
|
+
export { projectSafeJsonObject, redactJsonPaths } from './json.js';
|
|
6
|
+
export { hashUiDefinition } from './definition.js';
|
|
7
|
+
export { hasUiDefinitionLineageBreak, selectUiDefinitionLineageEntry, UiDefinitionLineageError, validateUiDefinitionLineage, } from './lineage.js';
|
|
8
|
+
export type { UiDefinitionLineageEntry, UiDefinitionLineageFailureCode, ValidatedUiDefinitionLineage, } from './lineage.js';
|
|
9
|
+
export { UiInstanceStore, openUiInstanceReadStore } from './store.js';
|
|
10
|
+
export type { UiAuditSnapshotInput, UiInstanceReadStore, UiInstanceRepinInput, UiInstanceRepinLedgerEntry, UiInstanceRepinResult, UiInstanceRepinWorkspaceInput, ReservationInput, } from './store.js';
|
|
11
|
+
export { createUiRuntimeForTest, createUiServerRuntime } from './runtime.js';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { JsonObject, JsonValue } from './types.js';
|
|
2
|
+
export declare function isProjectionUnsafeKey(key: string): boolean;
|
|
3
|
+
export type ProjectionRule = 'html' | 'url' | 'local_path' | 'sensitive_key' | 'path_key' | 'depth' | 'non_finite_number' | 'unsupported_type' | 'cycle' | 'not_object' | 'bad_options';
|
|
4
|
+
export interface ProjectionViolation {
|
|
5
|
+
readonly path: string;
|
|
6
|
+
readonly rule: ProjectionRule;
|
|
7
|
+
}
|
|
8
|
+
export interface FindProjectionViolationsOptions {
|
|
9
|
+
readonly envelopeDepth?: number;
|
|
10
|
+
readonly dataPaths?: readonly string[];
|
|
11
|
+
}
|
|
12
|
+
export declare function projectSafeJsonObject(value: unknown, envelopeDepth?: number, dataPaths?: readonly string[]): JsonObject;
|
|
13
|
+
export declare function findProjectionViolations(value: unknown, options?: FindProjectionViolationsOptions): ProjectionViolation[];
|
|
14
|
+
export declare function pathIsAtOrBelowPath(path: string, parentPath: string): boolean;
|
|
15
|
+
export declare function omitJsonPaths(value: JsonObject, dataPaths: readonly string[]): JsonObject;
|
|
16
|
+
export declare function redactJsonPaths(value: JsonObject, dataPaths: readonly string[], placeholder?: string): JsonObject;
|
|
17
|
+
export declare function serializeJson(value: JsonValue): string;
|
|
18
|
+
export declare function canonicalJson(value: JsonValue): string;
|
|
19
|
+
export declare function utf8ByteLength(value: string): number;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { UiDefinition, UiDefinitionInput, UiDefinitionRef } from './types.js';
|
|
2
|
+
export type UiDefinitionLineageFailureCode = 'LINEAGE_INVALID' | 'LINEAGE_STALE';
|
|
3
|
+
export interface UiDefinitionLineageEntry {
|
|
4
|
+
readonly version: number;
|
|
5
|
+
readonly hash: string;
|
|
6
|
+
readonly definition: UiDefinitionInput;
|
|
7
|
+
readonly sourceHash?: string;
|
|
8
|
+
readonly compat?: 'break';
|
|
9
|
+
}
|
|
10
|
+
export interface ValidatedUiDefinitionLineage {
|
|
11
|
+
readonly entries: readonly UiDefinitionLineageEntry[];
|
|
12
|
+
readonly current: UiDefinition;
|
|
13
|
+
}
|
|
14
|
+
export declare class UiDefinitionLineageError extends Error {
|
|
15
|
+
readonly code: UiDefinitionLineageFailureCode;
|
|
16
|
+
readonly violations: readonly string[];
|
|
17
|
+
readonly name = "UiDefinitionLineageError";
|
|
18
|
+
constructor(code: UiDefinitionLineageFailureCode, message?: string, violations?: readonly string[]);
|
|
19
|
+
}
|
|
20
|
+
export declare function validateUiDefinitionLineage(entriesValue: unknown, currentValue: unknown): ValidatedUiDefinitionLineage;
|
|
21
|
+
export declare function selectUiDefinitionLineageEntry(entries: unknown, current: unknown, selected: UiDefinitionRef): UiDefinition;
|
|
22
|
+
export declare function hasUiDefinitionLineageBreak(lineage: ValidatedUiDefinitionLineage, from: UiDefinitionRef, to?: UiDefinitionRef): boolean;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { UiRuntimeFacade, UiRuntimeOptions, UiServerRuntimeFacade, UiServerRuntimeOptions } from './types.js';
|
|
2
|
+
import { UiInstanceStore } from './store.js';
|
|
3
|
+
export interface UiRuntimeTestHooks {
|
|
4
|
+
beforeReservation?: () => Promise<void> | void;
|
|
5
|
+
injectDatabaseError?: () => unknown | undefined;
|
|
6
|
+
bumpRevisionBeforeCas?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface UiRuntimeForTestOptions extends UiRuntimeOptions {
|
|
9
|
+
workspaceId: string;
|
|
10
|
+
testHooks?: UiRuntimeTestHooks;
|
|
11
|
+
store?: UiInstanceStore;
|
|
12
|
+
}
|
|
13
|
+
export interface UiRuntimeStoreOptions {
|
|
14
|
+
readonly store?: UiInstanceStore;
|
|
15
|
+
}
|
|
16
|
+
export declare function createUiRuntime(workspaceId: string, options: UiRuntimeOptions & UiRuntimeStoreOptions): UiRuntimeFacade;
|
|
17
|
+
export declare function createUiRuntimeForTest(options: UiRuntimeForTestOptions): UiRuntimeFacade;
|
|
18
|
+
export declare function createUiServerRuntime(options: UiServerRuntimeOptions & UiRuntimeStoreOptions): UiServerRuntimeFacade;
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import type { UiDefinitionLineageEntry } from './lineage.js';
|
|
2
|
+
import type { ActionReceipt, ActionReceiptOutcome, UiApprovalDecisionProvenance, UiApprovalPendingReceipt, UiApprovalRequestReceiptResult, JsonObject, UiActionHandlerContext, UiActor, UiInstance, UiAuthenticatedActor, UiDefinition, UiDefinitionRef } from './types.js';
|
|
3
|
+
export type UiInstanceDataPathResolver = (definition: UiDefinitionRef) => readonly string[];
|
|
4
|
+
interface UiInstanceStoreTestHooks {
|
|
5
|
+
injectDatabaseError?: () => unknown | undefined;
|
|
6
|
+
bumpRevisionBeforeCas?: boolean;
|
|
7
|
+
beforeOpenRead?: () => void;
|
|
8
|
+
bumpRevisionBeforeRepinCas?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface ReservationInput {
|
|
11
|
+
instanceId: string;
|
|
12
|
+
definition?: UiDefinitionRef;
|
|
13
|
+
requestId: string;
|
|
14
|
+
actionId: string;
|
|
15
|
+
actor: UiActor;
|
|
16
|
+
source: 'cli' | 'ui_host' | 'system' | 'mcp';
|
|
17
|
+
expectedRevision: number;
|
|
18
|
+
input: JsonObject;
|
|
19
|
+
dataPaths?: readonly string[];
|
|
20
|
+
receiptInput?: JsonObject;
|
|
21
|
+
now: number;
|
|
22
|
+
}
|
|
23
|
+
export interface UiInstanceRepinInput {
|
|
24
|
+
readonly instanceId: string;
|
|
25
|
+
readonly workspaceId: string;
|
|
26
|
+
readonly appId: string;
|
|
27
|
+
readonly currentDefinition: UiDefinition;
|
|
28
|
+
readonly lineage: readonly UiDefinitionLineageEntry[];
|
|
29
|
+
readonly observedRevision: number;
|
|
30
|
+
readonly hasSkillActions: boolean;
|
|
31
|
+
readonly now: number;
|
|
32
|
+
}
|
|
33
|
+
export type UiInstanceRepinWorkspaceInput = Omit<UiInstanceRepinInput, 'instanceId' | 'observedRevision'>;
|
|
34
|
+
export interface UiInstanceRepinLedgerEntry {
|
|
35
|
+
readonly instanceId: string;
|
|
36
|
+
readonly fromVersion: number;
|
|
37
|
+
readonly fromHash: string;
|
|
38
|
+
readonly toVersion: number;
|
|
39
|
+
readonly toHash: string;
|
|
40
|
+
readonly fromRevision: number;
|
|
41
|
+
readonly toRevision: number | null;
|
|
42
|
+
readonly status: 'applied' | 'deferred' | 'failed';
|
|
43
|
+
readonly code: string | null;
|
|
44
|
+
readonly attempts: number;
|
|
45
|
+
readonly firstAt: number;
|
|
46
|
+
readonly lastAt: number;
|
|
47
|
+
}
|
|
48
|
+
export interface UiInstanceRepinResult extends UiInstanceRepinLedgerEntry {
|
|
49
|
+
}
|
|
50
|
+
export interface ApprovalPendingReservationInput {
|
|
51
|
+
readonly reservation: ReservationInput;
|
|
52
|
+
readonly approvalId: string;
|
|
53
|
+
readonly expiresAt: number;
|
|
54
|
+
}
|
|
55
|
+
export type ApprovalPendingReservationResult = {
|
|
56
|
+
readonly kind: 'reserved';
|
|
57
|
+
readonly reservation: ExternalReservation;
|
|
58
|
+
} | {
|
|
59
|
+
readonly kind: 'settled';
|
|
60
|
+
readonly receipt: ActionReceipt;
|
|
61
|
+
};
|
|
62
|
+
interface ApprovalReceiptMarker {
|
|
63
|
+
state: 'pending' | 'executing' | 'settled';
|
|
64
|
+
approvalId: string;
|
|
65
|
+
expiresAt: number;
|
|
66
|
+
decidedBy?: string;
|
|
67
|
+
}
|
|
68
|
+
interface ApprovalReceiptRecord {
|
|
69
|
+
readonly receipt: ActionReceipt;
|
|
70
|
+
readonly definition: UiDefinitionRef | null;
|
|
71
|
+
readonly approvalId: string;
|
|
72
|
+
readonly expiresAt: number;
|
|
73
|
+
readonly state: ApprovalReceiptMarker['state'];
|
|
74
|
+
}
|
|
75
|
+
export interface StateHandlerExecution {
|
|
76
|
+
handle: (context: UiActionHandlerContext) => {
|
|
77
|
+
state?: JsonObject;
|
|
78
|
+
result?: JsonObject;
|
|
79
|
+
} | {
|
|
80
|
+
outcome: 'rejected' | 'failed';
|
|
81
|
+
errorCode: string;
|
|
82
|
+
state?: JsonObject;
|
|
83
|
+
result?: JsonObject;
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
export interface ExternalReservation {
|
|
87
|
+
instance: UiInstance;
|
|
88
|
+
receipt: ActionReceipt;
|
|
89
|
+
reservedRevision: number;
|
|
90
|
+
reservationMarker: number;
|
|
91
|
+
}
|
|
92
|
+
export interface UiAuditSnapshotInput {
|
|
93
|
+
instanceId: string;
|
|
94
|
+
workspaceId: string;
|
|
95
|
+
updatedAt: number;
|
|
96
|
+
state: JsonObject;
|
|
97
|
+
dataPaths?: readonly string[];
|
|
98
|
+
}
|
|
99
|
+
export interface UiInstanceReadStore {
|
|
100
|
+
get(instanceId: string): UiInstance | null;
|
|
101
|
+
listByThread(workspaceId: string, threadId: string): UiInstance[];
|
|
102
|
+
listUnboundByApp(workspaceId: string, appId: string): UiInstance[];
|
|
103
|
+
getThreadBinding(workspaceId: string, threadId: string): ThreadBinding;
|
|
104
|
+
close(): void;
|
|
105
|
+
}
|
|
106
|
+
type ThreadBinding = 'bound' | 'unbound' | 'conflict';
|
|
107
|
+
export declare function openUiInstanceReadStore(dbPath?: string, resolveDataPaths?: UiInstanceDataPathResolver): UiInstanceReadStore;
|
|
108
|
+
export declare class UiInstanceStore {
|
|
109
|
+
private readonly handle;
|
|
110
|
+
private readonly db;
|
|
111
|
+
private readonly testHooks?;
|
|
112
|
+
constructor(dbPath?: string, testHooks?: UiInstanceStoreTestHooks);
|
|
113
|
+
close(): void;
|
|
114
|
+
repinInstance(input: UiInstanceRepinInput): UiInstanceRepinResult | null;
|
|
115
|
+
repinWorkspaceApp(input: UiInstanceRepinWorkspaceInput): UiInstanceRepinResult[];
|
|
116
|
+
getRepinLedgerEntry(instanceId: string, workspaceId: string, appId: string, toHash: string): UiInstanceRepinLedgerEntry | null;
|
|
117
|
+
listRepinLedgerEntries(workspaceId: string, appId: string, toHash: string): UiInstanceRepinLedgerEntry[];
|
|
118
|
+
private writeRepinLedger;
|
|
119
|
+
create(input: {
|
|
120
|
+
id: string;
|
|
121
|
+
definitionId: string;
|
|
122
|
+
definitionVersion: number;
|
|
123
|
+
definitionHash: string;
|
|
124
|
+
workspaceId: string;
|
|
125
|
+
threadId: string;
|
|
126
|
+
appId?: string | null;
|
|
127
|
+
anchorTaskId: string | null;
|
|
128
|
+
domainRef: JsonObject;
|
|
129
|
+
state: JsonObject;
|
|
130
|
+
dataPaths?: readonly string[];
|
|
131
|
+
grants: readonly string[];
|
|
132
|
+
openedBy?: UiAuthenticatedActor | null;
|
|
133
|
+
now: number;
|
|
134
|
+
}): UiInstance;
|
|
135
|
+
get(instanceId: string, resolveDataPaths?: UiInstanceDataPathResolver): UiInstance | null;
|
|
136
|
+
open(input: {
|
|
137
|
+
id?: string;
|
|
138
|
+
appId: string;
|
|
139
|
+
definitionId: string;
|
|
140
|
+
definitionVersion: number;
|
|
141
|
+
definitionHash: string;
|
|
142
|
+
workspaceId: string;
|
|
143
|
+
threadId: string;
|
|
144
|
+
anchorTaskId?: string | null;
|
|
145
|
+
domainRef: JsonObject;
|
|
146
|
+
state: JsonObject;
|
|
147
|
+
dataPaths?: readonly string[];
|
|
148
|
+
grants: readonly string[];
|
|
149
|
+
openedBy?: UiAuthenticatedActor | null;
|
|
150
|
+
now: number;
|
|
151
|
+
}): UiInstance;
|
|
152
|
+
listByThread(workspaceId: string, threadId: string, resolveDataPaths?: UiInstanceDataPathResolver): UiInstance[];
|
|
153
|
+
listUnboundByApp(workspaceId: string, appId: string, resolveDataPaths?: UiInstanceDataPathResolver): UiInstance[];
|
|
154
|
+
getThreadBinding(workspaceId: string, threadId: string): ThreadBinding;
|
|
155
|
+
updateAuditSnapshot(input: UiAuditSnapshotInput): UiInstance | null;
|
|
156
|
+
getReceipt(instanceId: string, requestId: string): ActionReceipt | null;
|
|
157
|
+
listRecentReceipts(instanceId: string, limit: number): ActionReceipt[];
|
|
158
|
+
getReceiptById(receiptId: string): ActionReceipt | null;
|
|
159
|
+
createApprovalPendingReceipt(reservation: ReservationInput, approval: {
|
|
160
|
+
readonly approvalId: string;
|
|
161
|
+
readonly expiresAt: number;
|
|
162
|
+
}): UiApprovalRequestReceiptResult;
|
|
163
|
+
getApprovalPendingReceipt(receiptId: string): UiApprovalPendingReceipt | null;
|
|
164
|
+
getApprovalReceipt(receiptId: string): ApprovalReceiptRecord | null;
|
|
165
|
+
listApprovalPendingReceipts(): UiApprovalPendingReceipt[];
|
|
166
|
+
settleApprovalPendingReceipt(receiptId: string, outcome: 'rejected' | 'expired' | 'conflicted', provenance: UiApprovalDecisionProvenance, now: number): ActionReceipt | null;
|
|
167
|
+
getLatestReceiptForInstance(instanceId: string): ActionReceipt | null;
|
|
168
|
+
runStateOnly(reservation: ReservationInput, handler: StateHandlerExecution['handle']): ActionReceipt;
|
|
169
|
+
reserveExternal(reservation: ReservationInput): ExternalReservation;
|
|
170
|
+
reserveApprovalPendingReceipt(reservation: ReservationInput, receiptId: string, provenance: UiApprovalDecisionProvenance): ApprovalPendingReservationResult;
|
|
171
|
+
settleExternal(input: {
|
|
172
|
+
reservation: ReservationInput;
|
|
173
|
+
reservedRevision: number;
|
|
174
|
+
reservationMarker: number;
|
|
175
|
+
outcome: ActionReceiptOutcome;
|
|
176
|
+
state: JsonObject;
|
|
177
|
+
resultSummary: JsonObject | null;
|
|
178
|
+
errorCode: string | null;
|
|
179
|
+
apply?: () => ReturnType<StateHandlerExecution['handle']>;
|
|
180
|
+
restoreRevisionOnFailure?: boolean;
|
|
181
|
+
now: number;
|
|
182
|
+
}): ActionReceipt;
|
|
183
|
+
}
|
|
184
|
+
export {};
|
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
import type { ContentFrame, UiActionContentDeclaration, UiContentChannelPort, UiContentRangeRequest } from '../mcp-app/content-channel.js';
|
|
2
|
+
export type JsonPrimitive = string | number | boolean | null;
|
|
3
|
+
export type JsonValue = JsonPrimitive | JsonObject | JsonValue[];
|
|
4
|
+
export interface JsonObject {
|
|
5
|
+
[key: string]: JsonValue;
|
|
6
|
+
}
|
|
7
|
+
export type UiInstanceStatus = 'active' | 'completed' | 'expired' | 'revoked' | 'unsupported';
|
|
8
|
+
export interface UiDefinitionRef {
|
|
9
|
+
id: string;
|
|
10
|
+
version: number;
|
|
11
|
+
hash: string;
|
|
12
|
+
}
|
|
13
|
+
export type UiDefinitionUsage = 'card' | 'window';
|
|
14
|
+
export type UiDefinitionDisplayMode = 'inline' | 'floating' | 'focused';
|
|
15
|
+
export declare const DEFAULT_UI_DEFINITION_USAGE: UiDefinitionUsage;
|
|
16
|
+
export type UiActionConfirmation = 'none' | 'native';
|
|
17
|
+
export type UiSkillBackendEnvironmentKey = 'CREWX_APP_INSTANCE_ID' | 'CREWX_THREAD_ID';
|
|
18
|
+
export interface UiDefinitionAction {
|
|
19
|
+
readonly capabilities: readonly string[];
|
|
20
|
+
readonly inputKeys?: readonly string[];
|
|
21
|
+
readonly dataInputs?: readonly string[];
|
|
22
|
+
readonly confirmation?: UiActionConfirmation;
|
|
23
|
+
readonly resultProjection?: UiProjectionPolicy;
|
|
24
|
+
readonly content?: UiActionContentDeclaration;
|
|
25
|
+
readonly env?: readonly UiSkillBackendEnvironmentKey[];
|
|
26
|
+
}
|
|
27
|
+
export interface UiProjectionPolicy {
|
|
28
|
+
allow: readonly string[];
|
|
29
|
+
}
|
|
30
|
+
export type UiDefinitionLegacyToolVisibility = 'model' | 'app';
|
|
31
|
+
export interface UiDefinitionLegacyTool {
|
|
32
|
+
readonly name: string;
|
|
33
|
+
readonly description: string;
|
|
34
|
+
readonly inputSchema: JsonObject;
|
|
35
|
+
readonly textFallback: string;
|
|
36
|
+
readonly visibility: readonly UiDefinitionLegacyToolVisibility[];
|
|
37
|
+
}
|
|
38
|
+
export interface UiDefinitionLegacyReadTool extends UiDefinitionLegacyTool {
|
|
39
|
+
readonly fixedResult?: {
|
|
40
|
+
readonly structuredContent: JsonObject;
|
|
41
|
+
readonly argsPolicy: 'empty-only' | 'ignore';
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
export interface UiDefinitionLegacyMetadata {
|
|
45
|
+
readonly readTool?: UiDefinitionLegacyReadTool;
|
|
46
|
+
readonly actionTool?: UiDefinitionLegacyTool;
|
|
47
|
+
readonly hostTools?: Readonly<Record<string, string>>;
|
|
48
|
+
readonly agentAccess?: Readonly<Record<string, 'allowed' | 'denied'>>;
|
|
49
|
+
}
|
|
50
|
+
export interface UiDefinitionInput {
|
|
51
|
+
readonly id: string;
|
|
52
|
+
readonly version: number;
|
|
53
|
+
readonly sourceHash?: string;
|
|
54
|
+
readonly usage?: UiDefinitionUsage;
|
|
55
|
+
readonly detailPanel?: boolean;
|
|
56
|
+
readonly displayModes?: readonly UiDefinitionDisplayMode[];
|
|
57
|
+
readonly actions: Readonly<Record<string, UiDefinitionAction>>;
|
|
58
|
+
readonly renderer?: string;
|
|
59
|
+
readonly surfaces?: readonly string[];
|
|
60
|
+
readonly stateProjection?: UiProjectionPolicy;
|
|
61
|
+
readonly dataPaths?: readonly string[];
|
|
62
|
+
readonly summaryProjection?: UiProjectionPolicy;
|
|
63
|
+
readonly legacy?: UiDefinitionLegacyMetadata;
|
|
64
|
+
}
|
|
65
|
+
export interface UiDefinition extends UiDefinitionInput {
|
|
66
|
+
readonly hash: string;
|
|
67
|
+
}
|
|
68
|
+
export interface CreateUiInstanceInput {
|
|
69
|
+
definition: UiDefinitionRef;
|
|
70
|
+
workspaceId: string;
|
|
71
|
+
threadId: string;
|
|
72
|
+
anchorTaskId?: string;
|
|
73
|
+
domainRef: JsonObject;
|
|
74
|
+
state: JsonObject;
|
|
75
|
+
}
|
|
76
|
+
export interface UiInstance {
|
|
77
|
+
id: string;
|
|
78
|
+
definition: UiDefinitionRef;
|
|
79
|
+
workspaceId: string;
|
|
80
|
+
threadId: string;
|
|
81
|
+
appId: string | null;
|
|
82
|
+
anchorTaskId: string | null;
|
|
83
|
+
domainRef: JsonObject;
|
|
84
|
+
state: JsonObject;
|
|
85
|
+
revision: number;
|
|
86
|
+
status: UiInstanceStatus;
|
|
87
|
+
grantedCapabilities: readonly string[];
|
|
88
|
+
openedBy?: UiAuthenticatedActor | null;
|
|
89
|
+
createdAt: number;
|
|
90
|
+
updatedAt: number;
|
|
91
|
+
}
|
|
92
|
+
export interface UiActionEnvelope {
|
|
93
|
+
instanceId: string;
|
|
94
|
+
actionId: string;
|
|
95
|
+
expectedRevision: number;
|
|
96
|
+
requestId: string;
|
|
97
|
+
input: JsonObject;
|
|
98
|
+
resolvedDefinition?: UiDefinitionRef;
|
|
99
|
+
content?: {
|
|
100
|
+
in?: {
|
|
101
|
+
readonly ticket: string;
|
|
102
|
+
readonly sha256: string;
|
|
103
|
+
};
|
|
104
|
+
out?: {
|
|
105
|
+
readonly range?: UiContentRangeRequest;
|
|
106
|
+
};
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
export type UiActor = {
|
|
110
|
+
kind: 'local';
|
|
111
|
+
id: string;
|
|
112
|
+
} | UiAuthenticatedActor | {
|
|
113
|
+
kind: 'agent';
|
|
114
|
+
id: string;
|
|
115
|
+
};
|
|
116
|
+
export interface UiExecutionContext {
|
|
117
|
+
source: 'cli' | 'ui_host' | 'system' | 'mcp';
|
|
118
|
+
workspaceId: string;
|
|
119
|
+
actor: UiActor;
|
|
120
|
+
}
|
|
121
|
+
export interface UiAuthenticatedActor {
|
|
122
|
+
kind: 'authenticated';
|
|
123
|
+
id: string;
|
|
124
|
+
task?: UiTaskActorSnapshot;
|
|
125
|
+
}
|
|
126
|
+
export interface UiTaskActorSnapshot {
|
|
127
|
+
taskId: string;
|
|
128
|
+
agentId: string;
|
|
129
|
+
threadId: string;
|
|
130
|
+
workspaceId: string;
|
|
131
|
+
parentTaskId: string | null;
|
|
132
|
+
parentTaskIds: readonly string[];
|
|
133
|
+
}
|
|
134
|
+
export declare function isUiAuthenticatedActor(value: unknown): value is UiAuthenticatedActor;
|
|
135
|
+
export interface UiAuthenticatedExecutionContext {
|
|
136
|
+
source: 'ui_host' | 'system';
|
|
137
|
+
workspaceId: string;
|
|
138
|
+
threadId: string;
|
|
139
|
+
actor: UiAuthenticatedActor;
|
|
140
|
+
}
|
|
141
|
+
export interface UiApprovalRequestContext {
|
|
142
|
+
source: 'cli';
|
|
143
|
+
workspaceId: string;
|
|
144
|
+
threadId: string;
|
|
145
|
+
actor: UiAuthenticatedActor;
|
|
146
|
+
}
|
|
147
|
+
export interface UiTaskExecutionContext {
|
|
148
|
+
source: 'cli';
|
|
149
|
+
workspaceId: string;
|
|
150
|
+
threadId: string;
|
|
151
|
+
actor: UiAuthenticatedActor & {
|
|
152
|
+
task: UiTaskActorSnapshot;
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
export interface UiApprovalDecisionProvenance {
|
|
156
|
+
approvalId: string;
|
|
157
|
+
decidedBy: string;
|
|
158
|
+
}
|
|
159
|
+
export interface UiApprovalPendingReceipt {
|
|
160
|
+
receipt: ActionReceipt;
|
|
161
|
+
approvalId: string;
|
|
162
|
+
expiresAt: number;
|
|
163
|
+
}
|
|
164
|
+
export interface UiApprovalRequestReceiptResult {
|
|
165
|
+
receipt: ActionReceipt;
|
|
166
|
+
approval: {
|
|
167
|
+
approvalId: string;
|
|
168
|
+
expiresAt: number;
|
|
169
|
+
} | null;
|
|
170
|
+
}
|
|
171
|
+
export type ActionReceiptOutcome = 'succeeded' | 'rejected' | 'failed' | 'conflicted' | 'expired';
|
|
172
|
+
export interface ActionReceiptResultSummary {
|
|
173
|
+
readonly crewxResult?: {
|
|
174
|
+
readonly keys: readonly string[];
|
|
175
|
+
readonly bytes: number;
|
|
176
|
+
readonly sha256: string;
|
|
177
|
+
};
|
|
178
|
+
readonly crewxContent?: JsonObject;
|
|
179
|
+
}
|
|
180
|
+
export interface ActionReceipt {
|
|
181
|
+
id: string;
|
|
182
|
+
instanceId: string;
|
|
183
|
+
requestId: string;
|
|
184
|
+
actionId: string;
|
|
185
|
+
actor: UiActor;
|
|
186
|
+
source: 'cli' | 'ui_host' | 'system' | 'mcp';
|
|
187
|
+
expectedRevision: number;
|
|
188
|
+
beforeRevision: number;
|
|
189
|
+
afterRevision: number | null;
|
|
190
|
+
status: 'requested' | 'settled';
|
|
191
|
+
outcome: ActionReceiptOutcome | null;
|
|
192
|
+
input: JsonObject;
|
|
193
|
+
resultSummary: ActionReceiptResultSummary | null;
|
|
194
|
+
errorCode: string | null;
|
|
195
|
+
requestedAt: number;
|
|
196
|
+
settledAt: number | null;
|
|
197
|
+
}
|
|
198
|
+
export interface ActionExecutionReceipt extends ActionReceipt {
|
|
199
|
+
actionResult?: JsonObject;
|
|
200
|
+
}
|
|
201
|
+
export interface UiLocalGrantPolicy {
|
|
202
|
+
resolveInstanceGrants(input: {
|
|
203
|
+
definition: UiDefinitionRef;
|
|
204
|
+
workspaceId: string;
|
|
205
|
+
actor: Extract<UiActor, {
|
|
206
|
+
kind: 'local';
|
|
207
|
+
}>;
|
|
208
|
+
}): readonly string[];
|
|
209
|
+
resolveActionCapabilities(input: {
|
|
210
|
+
definition: UiDefinitionRef;
|
|
211
|
+
actionId: string;
|
|
212
|
+
}): readonly string[];
|
|
213
|
+
}
|
|
214
|
+
export interface UiActionHandlerContext {
|
|
215
|
+
instance: UiInstance;
|
|
216
|
+
actor: UiActor;
|
|
217
|
+
source: 'cli' | 'ui_host' | 'system' | 'mcp';
|
|
218
|
+
input: JsonObject;
|
|
219
|
+
requestId: string;
|
|
220
|
+
reservationNow?: number;
|
|
221
|
+
content?: {
|
|
222
|
+
readonly in?: ContentFrame;
|
|
223
|
+
readonly out?: {
|
|
224
|
+
readonly range?: UiContentRangeRequest;
|
|
225
|
+
};
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
export type UiActionHandlerResult = {
|
|
229
|
+
state?: JsonObject;
|
|
230
|
+
result?: JsonObject;
|
|
231
|
+
content?: ContentFrame;
|
|
232
|
+
} | {
|
|
233
|
+
outcome: 'rejected' | 'failed';
|
|
234
|
+
errorCode: string;
|
|
235
|
+
state?: JsonObject;
|
|
236
|
+
result?: JsonObject;
|
|
237
|
+
content?: ContentFrame;
|
|
238
|
+
};
|
|
239
|
+
export interface UiStateActionHandlerRegistration {
|
|
240
|
+
definitionId: string;
|
|
241
|
+
version: number;
|
|
242
|
+
actionId: string;
|
|
243
|
+
kind: 'state';
|
|
244
|
+
handle: (context: UiActionHandlerContext) => UiActionHandlerResult;
|
|
245
|
+
}
|
|
246
|
+
export interface UiExternalActionHandlerRegistration {
|
|
247
|
+
definitionId: string;
|
|
248
|
+
version: number;
|
|
249
|
+
actionId: string;
|
|
250
|
+
kind: 'external';
|
|
251
|
+
handle: (context: UiActionHandlerContext) => Promise<UiActionHandlerResult>;
|
|
252
|
+
}
|
|
253
|
+
export type UiActionHandlerRegistration = UiStateActionHandlerRegistration | UiExternalActionHandlerRegistration;
|
|
254
|
+
export interface UiRuntimeOptions {
|
|
255
|
+
dbPath?: string;
|
|
256
|
+
localActor: Extract<UiActor, {
|
|
257
|
+
kind: 'local';
|
|
258
|
+
}>;
|
|
259
|
+
localGrantPolicy?: UiLocalGrantPolicy;
|
|
260
|
+
definitions?: readonly UiDefinition[];
|
|
261
|
+
handlers?: readonly UiActionHandlerRegistration[];
|
|
262
|
+
clock?: () => number;
|
|
263
|
+
contentChannel?: UiContentChannelPort;
|
|
264
|
+
}
|
|
265
|
+
export interface UiRuntimeFacade {
|
|
266
|
+
resolveDefinition(ref: UiDefinitionRef): UiDefinition | null;
|
|
267
|
+
createInstance(input: CreateUiInstanceInput): Promise<UiInstance>;
|
|
268
|
+
dispatchAction(input: UiActionEnvelope, context: UiExecutionContext): Promise<ActionExecutionReceipt>;
|
|
269
|
+
getReceipt(instanceId: string, requestId: string): Promise<ActionReceipt | null>;
|
|
270
|
+
close(): void;
|
|
271
|
+
}
|
|
272
|
+
export interface UiAuthenticatedGrantPolicy {
|
|
273
|
+
resolveInstanceGrants(input: {
|
|
274
|
+
definition: UiDefinitionRef;
|
|
275
|
+
workspaceId: string;
|
|
276
|
+
actor: UiAuthenticatedActor;
|
|
277
|
+
}): readonly string[];
|
|
278
|
+
resolveDispatchCapabilities?(input: {
|
|
279
|
+
definition: UiDefinitionRef;
|
|
280
|
+
actionId: string;
|
|
281
|
+
actor: UiAuthenticatedActor;
|
|
282
|
+
source: 'ui_host' | 'system' | 'cli';
|
|
283
|
+
}): readonly string[];
|
|
284
|
+
}
|
|
285
|
+
export declare function resolveUiEffectiveCapabilities(declared: readonly string[], instanceGranted: readonly string[], dispatchGranted?: readonly string[]): readonly string[];
|
|
286
|
+
export interface UiServerRuntimeOptions {
|
|
287
|
+
workspaceId: string;
|
|
288
|
+
dbPath: string;
|
|
289
|
+
definitions: readonly UiDefinition[];
|
|
290
|
+
handlers: readonly UiActionHandlerRegistration[];
|
|
291
|
+
grantPolicy: UiAuthenticatedGrantPolicy;
|
|
292
|
+
verifiedBundles?: readonly import('../mcp-app/agent-access.js').McpAppVerifiedBundleAccessContext[];
|
|
293
|
+
clock?: () => number;
|
|
294
|
+
contentChannel?: UiContentChannelPort;
|
|
295
|
+
}
|
|
296
|
+
export interface UiServerRuntimeFacade {
|
|
297
|
+
resolveDefinition(ref: UiDefinitionRef): UiDefinition | null;
|
|
298
|
+
getInstance(instanceId: string, context: UiAuthenticatedExecutionContext): Promise<UiInstance | null>;
|
|
299
|
+
createInstance(input: CreateUiInstanceInput, context: UiAuthenticatedExecutionContext): Promise<UiInstance>;
|
|
300
|
+
dispatchAction(input: UiActionEnvelope, context: UiAuthenticatedExecutionContext | UiTaskExecutionContext): Promise<ActionExecutionReceipt>;
|
|
301
|
+
getReceipt(instanceId: string, requestId: string, context: UiAuthenticatedExecutionContext): Promise<ActionReceipt | null>;
|
|
302
|
+
createApprovalPendingReceipt(input: UiActionEnvelope, context: UiApprovalRequestContext, approval: {
|
|
303
|
+
approvalId: string;
|
|
304
|
+
expiresAt: number;
|
|
305
|
+
}): Promise<UiApprovalRequestReceiptResult>;
|
|
306
|
+
executeApprovalPending(input: UiActionEnvelope, receiptId: string, provenance: UiApprovalDecisionProvenance): Promise<ActionExecutionReceipt>;
|
|
307
|
+
settleApprovalPending(receiptId: string, outcome: 'rejected' | 'expired' | 'conflicted', provenance: UiApprovalDecisionProvenance): Promise<ActionReceipt | null>;
|
|
308
|
+
listApprovalPendingReceipts(): Promise<UiApprovalPendingReceipt[]>;
|
|
309
|
+
close(): void;
|
|
310
|
+
}
|
|
311
|
+
export interface UiAgentContextProjection {
|
|
312
|
+
instanceId: string;
|
|
313
|
+
definition: UiDefinitionRef;
|
|
314
|
+
revision: number;
|
|
315
|
+
facts: JsonObject;
|
|
316
|
+
recentChanges: readonly JsonObject[];
|
|
317
|
+
pendingDecision: JsonObject | null;
|
|
318
|
+
availableActions: readonly string[];
|
|
319
|
+
}
|