@crewx/sdk 0.9.0-rc.15 → 0.9.0-rc.151
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 +148 -0
- package/dist/app/backend-env.d.ts +3 -0
- package/dist/app/content-media-types.d.ts +2 -0
- package/dist/app/context.d.ts +2 -0
- package/dist/app/entry.d.ts +7 -0
- package/dist/app/frame.d.ts +56 -0
- package/dist/app/index.d.ts +10 -0
- package/dist/app/index.js +10 -0
- package/dist/app/protocol.d.ts +9 -0
- package/dist/app/runtime.d.ts +21 -0
- package/dist/app/tool-mode.d.ts +3 -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 +10 -0
- package/dist/esm/desktop/index.js +3 -0
- package/dist/esm/index.js +1137 -226
- package/dist/esm/node/index.js +2 -0
- package/dist/esm/plugins/index.js +498 -216
- package/dist/esm/process/index.js +1 -0
- package/dist/esm/publish/index.js +2 -0
- package/dist/esm/repository/index.js +606 -209
- 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 +127 -17
- package/dist/index.js +1137 -226
- 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/candidate-registration.d.ts +4 -0
- package/dist/mcp-app/catalog.d.ts +7 -0
- package/dist/mcp-app/content-channel.d.ts +86 -0
- package/dist/mcp-app/content-declarations.d.ts +31 -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 +161 -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 +132 -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/0036_ui_definition_archive.sql +8 -0
- package/dist/migrations/0037_ui_instance_agent_open_request.sql +1 -0
- package/dist/migrations/0038_task_rating.sql +3 -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/0036_snapshot.json +3591 -0
- package/dist/migrations/meta/0037_snapshot.json +3598 -0
- package/dist/migrations/meta/0038_snapshot.json +3626 -0
- package/dist/migrations/meta/_journal.json +196 -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 +498 -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 +10 -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 +43 -5
- package/dist/repository/index.js +606 -209
- 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 +275 -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 +13 -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 +203 -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-definition-archive.d.ts +63 -0
- package/dist/schema/ui-instance-repins.d.ts +222 -0
- package/dist/schema/ui-instances.d.ts +324 -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 +24 -0
- package/dist/ui-instance/runtime.d.ts +18 -0
- package/dist/ui-instance/store.d.ts +210 -0
- package/dist/ui-instance/types.d.ts +327 -0
- package/dist/ui-plugin/app-manifest.d.ts +64 -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 +203 -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
package/README.md
CHANGED
|
@@ -128,7 +128,7 @@ const result = await crewx.query('assistant', 'Translate to Korean', {
|
|
|
128
128
|
});
|
|
129
129
|
```
|
|
130
130
|
|
|
131
|
-
> **Note**: `'@assistant'`
|
|
131
|
+
> **Note**: The `'@assistant'` form also works (CLI-compatible). The SDK recommends using the bare id.
|
|
132
132
|
|
|
133
133
|
**Returns**: [`QueryResult`](#queryresult)
|
|
134
134
|
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
export declare const DEVICE_CODE_PATH: "/auth/v1/oauth/device/code";
|
|
2
|
+
export declare const TOKEN_PATH: "/auth/v1/oauth/token";
|
|
3
|
+
export declare const REVOKE_PATH: "/auth/v1/oauth/revoke";
|
|
4
|
+
export declare const OAUTH_CLIENT_ID: "crewx-cli";
|
|
5
|
+
export declare const DEVICE_CODE_GRANT_TYPE: "urn:ietf:params:oauth:grant-type:device_code";
|
|
6
|
+
export interface DeviceCodeResponse {
|
|
7
|
+
device_code: string;
|
|
8
|
+
user_code: string;
|
|
9
|
+
verification_uri: string;
|
|
10
|
+
verification_uri_complete?: string;
|
|
11
|
+
expires_in: number;
|
|
12
|
+
interval?: number;
|
|
13
|
+
}
|
|
14
|
+
export type DeviceCodeResult = DeviceCodeResponse;
|
|
15
|
+
export interface AccountIdentity {
|
|
16
|
+
sub: string;
|
|
17
|
+
email: string;
|
|
18
|
+
}
|
|
19
|
+
export interface OAuthTokenResponse {
|
|
20
|
+
access_token: string;
|
|
21
|
+
refresh_token: string;
|
|
22
|
+
expires_in: number;
|
|
23
|
+
token_type?: string;
|
|
24
|
+
scope?: string;
|
|
25
|
+
account: AccountIdentity;
|
|
26
|
+
}
|
|
27
|
+
export type TokenResponse = OAuthTokenResponse;
|
|
28
|
+
export type AuthTokenGrant = {
|
|
29
|
+
grant_type: typeof DEVICE_CODE_GRANT_TYPE;
|
|
30
|
+
device_code: string;
|
|
31
|
+
} | {
|
|
32
|
+
grant_type: 'refresh_token';
|
|
33
|
+
refresh_token: string;
|
|
34
|
+
};
|
|
35
|
+
export interface AuthClientOptions {
|
|
36
|
+
baseUrl?: string;
|
|
37
|
+
fetch?: typeof fetch;
|
|
38
|
+
fetchImpl?: typeof fetch;
|
|
39
|
+
timeoutMs?: number;
|
|
40
|
+
}
|
|
41
|
+
export declare class AuthClient {
|
|
42
|
+
private readonly configuredBaseUrl?;
|
|
43
|
+
private readonly fetchImpl?;
|
|
44
|
+
private readonly timeoutMs;
|
|
45
|
+
constructor(options?: AuthClientOptions | string);
|
|
46
|
+
private baseUrl;
|
|
47
|
+
private signal;
|
|
48
|
+
private request;
|
|
49
|
+
requestDeviceCode(): Promise<DeviceCodeResponse>;
|
|
50
|
+
requestToken(grant: AuthTokenGrant): Promise<OAuthTokenResponse>;
|
|
51
|
+
exchangeDeviceCode(deviceCode: string): Promise<OAuthTokenResponse>;
|
|
52
|
+
refreshToken(refreshToken: string): Promise<OAuthTokenResponse>;
|
|
53
|
+
deviceCode(): Promise<DeviceCodeResponse>;
|
|
54
|
+
getDeviceCode(): Promise<DeviceCodeResponse>;
|
|
55
|
+
token(grant: AuthTokenGrant): Promise<OAuthTokenResponse>;
|
|
56
|
+
getToken(grant: AuthTokenGrant): Promise<OAuthTokenResponse>;
|
|
57
|
+
refresh(refreshToken: string): Promise<OAuthTokenResponse>;
|
|
58
|
+
refreshAccessToken(refreshToken: string): Promise<OAuthTokenResponse>;
|
|
59
|
+
revokeToken(refreshToken: string): Promise<void>;
|
|
60
|
+
revoke(refreshToken: string): Promise<void>;
|
|
61
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './auth-json';
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export declare const AUTH_JSON_FILENAME: "auth.json";
|
|
2
|
+
export declare const AUTH_JSON_VERSION: 2;
|
|
3
|
+
export interface AuthJsonV2 {
|
|
4
|
+
version: 2;
|
|
5
|
+
sub: string;
|
|
6
|
+
email: string;
|
|
7
|
+
access_token: string;
|
|
8
|
+
refresh_token: string;
|
|
9
|
+
expires_at: number;
|
|
10
|
+
updated_at: string;
|
|
11
|
+
}
|
|
12
|
+
export type AuthJson = AuthJsonV2;
|
|
13
|
+
export type AuthSession = AuthJsonV2;
|
|
14
|
+
export declare function isAuthJsonV2(value: unknown): value is AuthJsonV2;
|
|
15
|
+
export declare function validateAuthJson(value: unknown): AuthJsonV2;
|
|
16
|
+
export declare function parseAuthJson(raw: string): AuthJsonV2;
|
|
17
|
+
export declare function authJsonPath(filePath?: string): string;
|
|
18
|
+
export declare class AuthJsonStore {
|
|
19
|
+
private readonly configuredPath?;
|
|
20
|
+
constructor(options?: {
|
|
21
|
+
filePath?: string;
|
|
22
|
+
} | string);
|
|
23
|
+
path(): string;
|
|
24
|
+
read(): AuthJsonV2 | null;
|
|
25
|
+
write(value: AuthJsonV2): void;
|
|
26
|
+
clear(): void;
|
|
27
|
+
}
|
|
28
|
+
export declare function readAuthJson(filePath?: string): AuthJsonV2;
|
|
29
|
+
export declare function writeAuthJson(value: AuthJsonV2, filePath?: string): void;
|
|
30
|
+
export declare function clearAuthJson(filePath?: string): void;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export declare const ACCOUNT_BASE_URL_ENV: "CREWX_ACCOUNT_BASE_URL";
|
|
2
|
+
export declare const ACCOUNT_ISSUER_ENV: "CREWX_ACCOUNT_ISSUER";
|
|
3
|
+
export declare const MARKETPLACE_URL_ENV: "CREWX_MARKETPLACE_URL";
|
|
4
|
+
export declare const ACCOUNT_TARGET_ENV: "CREWX_TARGET";
|
|
5
|
+
export declare const MARKETPLACE_DISABLED_ENV: "CREWX_MARKETPLACE_DISABLED";
|
|
6
|
+
export declare const PRODUCTION_TARGET: Readonly<{
|
|
7
|
+
readonly accountBaseUrl: "https://app.sowonai.com";
|
|
8
|
+
readonly marketplaceUrl: "https://market.sowonai.com";
|
|
9
|
+
}>;
|
|
10
|
+
export declare const LOCAL_TARGET: Readonly<{
|
|
11
|
+
readonly accountBaseUrl: "http://127.0.0.1:3030";
|
|
12
|
+
readonly marketplaceUrl: "http://127.0.0.1:4000";
|
|
13
|
+
}>;
|
|
14
|
+
export declare const DEFAULT_ACCEPTED_ISSUERS: readonly ["https://app.sowonai.com/auth/v1", "https://auth.sowonai.com/auth/v1"];
|
|
15
|
+
export type Environment = Readonly<Record<string, string | undefined>>;
|
|
16
|
+
export type AccountTargetProfile = 'production' | 'local' | 'custom';
|
|
17
|
+
export type AccountTargetSource = 'env' | 'profile' | 'default' | 'disabled';
|
|
18
|
+
export interface AccountTarget {
|
|
19
|
+
accountBaseUrl: string;
|
|
20
|
+
marketplaceUrl: string | null;
|
|
21
|
+
issuers: readonly string[];
|
|
22
|
+
profile: AccountTargetProfile;
|
|
23
|
+
sources: {
|
|
24
|
+
accountBaseUrl: Exclude<AccountTargetSource, 'disabled'>;
|
|
25
|
+
marketplaceUrl: AccountTargetSource;
|
|
26
|
+
issuer: Exclude<AccountTargetSource, 'disabled'>;
|
|
27
|
+
};
|
|
28
|
+
mixed: boolean;
|
|
29
|
+
marketplaceDisabled: boolean;
|
|
30
|
+
}
|
|
31
|
+
export declare function resolveAccountBaseUrl(env?: Environment): string;
|
|
32
|
+
export declare function resolveMarketplaceUrl(env?: Environment): string;
|
|
33
|
+
export declare function resolveAcceptedAccountIssuers(env?: Environment): readonly string[];
|
|
34
|
+
export declare function resolveAccountIssuer(env?: Environment): string;
|
|
35
|
+
export declare function resolveAccountTarget(env?: Environment): AccountTarget;
|
|
36
|
+
export declare function assertAccountTargetNotMixed(env?: Environment): void;
|
|
37
|
+
export declare function appendEndpoint(baseUrl: string, endpoint: string): string;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const CREWX_TASK_TICKET_SECRET_ENV: "CREWX_TASK_TICKET_SECRET";
|
|
2
|
+
export interface CrewxEnvFileOptions {
|
|
3
|
+
workspaceDir?: string;
|
|
4
|
+
homeDir?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function resolveCrewxEnvFilePaths(options?: CrewxEnvFileOptions): {
|
|
7
|
+
workspace: string;
|
|
8
|
+
home: string;
|
|
9
|
+
};
|
|
10
|
+
export declare function readCrewxEnvFileKeys(path: string): ReadonlySet<string>;
|
|
11
|
+
export declare function loadCrewxEnvFiles(options?: CrewxEnvFileOptions): void;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export type AccountAuthErrorKind = 'configuration' | 'network' | 'server' | 'invalid_refresh' | 'pending' | 'denied' | 'expired' | 'http' | 'protocol';
|
|
2
|
+
export declare class AccountAuthError extends Error {
|
|
3
|
+
readonly code: string;
|
|
4
|
+
readonly kind: AccountAuthErrorKind;
|
|
5
|
+
readonly status?: number;
|
|
6
|
+
constructor(code: string, kind: AccountAuthErrorKind, status?: number, message?: string);
|
|
7
|
+
}
|
|
8
|
+
export { AccountAuthError as AuthClientError, AccountAuthError as AuthError };
|
|
9
|
+
export declare class LoginRequiredError extends Error {
|
|
10
|
+
readonly code: "LOGIN_REQUIRED";
|
|
11
|
+
constructor();
|
|
12
|
+
}
|
|
13
|
+
export declare class SessionManagerError extends Error {
|
|
14
|
+
readonly code: string;
|
|
15
|
+
constructor(code: string, message: string);
|
|
16
|
+
}
|
|
17
|
+
export type AuthJsonValidationCode = 'AUTH_JSON_LEGACY' | 'AUTH_JSON_INVALID';
|
|
18
|
+
export declare class AuthJsonValidationError extends Error {
|
|
19
|
+
readonly code: AuthJsonValidationCode;
|
|
20
|
+
constructor(code: AuthJsonValidationCode, message?: string);
|
|
21
|
+
}
|
|
22
|
+
export declare class AccountConfigurationError extends AccountAuthError {
|
|
23
|
+
constructor(code: 'ACCOUNT_BASE_URL_MISSING' | 'ACCOUNT_BASE_URL_INVALID' | 'ACCOUNT_ISSUER_MISSING' | 'ACCOUNT_ISSUER_INVALID' | 'MARKETPLACE_URL_MISSING' | 'MARKETPLACE_URL_INVALID' | 'ACCOUNT_TARGET_INVALID' | 'ACCOUNT_TARGET_MIXED' | 'MARKETPLACE_DISABLED');
|
|
24
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { ACCOUNT_BASE_URL_ENV, ACCOUNT_ISSUER_ENV, ACCOUNT_TARGET_ENV, DEFAULT_ACCEPTED_ISSUERS, LOCAL_TARGET, MARKETPLACE_DISABLED_ENV, MARKETPLACE_URL_ENV, PRODUCTION_TARGET, appendEndpoint, assertAccountTargetNotMixed, resolveAccountBaseUrl, resolveAccountTarget, resolveAcceptedAccountIssuers, resolveAccountIssuer, resolveMarketplaceUrl, } from './config';
|
|
2
|
+
export type { AccountTarget, AccountTargetProfile, AccountTargetSource, Environment, } from './config';
|
|
3
|
+
export { CREWX_TASK_TICKET_SECRET_ENV, loadCrewxEnvFiles, readCrewxEnvFileKeys, resolveCrewxEnvFilePaths, } from './env-bootstrap';
|
|
4
|
+
export type { CrewxEnvFileOptions } from './env-bootstrap';
|
|
5
|
+
export { AccountAuthError, AuthClientError, AuthError, AccountConfigurationError, AuthJsonValidationError, LoginRequiredError, SessionManagerError, } from './errors';
|
|
6
|
+
export type { AccountAuthErrorKind, AuthJsonValidationCode } from './errors';
|
|
7
|
+
export { AUTH_JSON_FILENAME, AUTH_JSON_VERSION, AuthJsonStore, authJsonPath, clearAuthJson, isAuthJsonV2, parseAuthJson, readAuthJson, validateAuthJson, writeAuthJson, } from './auth-json';
|
|
8
|
+
export type { AuthJson, AuthJsonV2, AuthSession } from './auth-json';
|
|
9
|
+
export { AuthClient, DEVICE_CODE_GRANT_TYPE, DEVICE_CODE_PATH, OAUTH_CLIENT_ID, REVOKE_PATH, TOKEN_PATH, } from './auth-client';
|
|
10
|
+
export type { AccountIdentity, AuthClientOptions, AuthTokenGrant, DeviceCodeResponse, DeviceCodeResult, OAuthTokenResponse, TokenResponse, } from './auth-client';
|
|
11
|
+
export { SessionManager } from './session-manager';
|
|
12
|
+
export type { AccountAuthClient, AuthJsonStorage, AuthSessionStore, SessionManagerOptions } from './session-manager';
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use strict';var dotenv=require('dotenv'),z=require('fs'),T=require('path'),$=require('os'),crypto=require('crypto');function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var z__namespace=/*#__PURE__*/_interopNamespace(z);var T__namespace=/*#__PURE__*/_interopNamespace(T);var $__namespace=/*#__PURE__*/_interopNamespace($);var s=class extends Error{code;kind;status;constructor(e,n,r,o){super(o??`Account authentication request failed (${e})`),this.name="AccountAuthError",this.code=e,this.kind=n,this.status=r;}};var l=class extends Error{code="LOGIN_REQUIRED";constructor(){super("Login required \u2014 please log in again"),this.name="LoginRequiredError";}},f=class extends Error{code;constructor(e,n){super(n),this.name="SessionManagerError",this.code=e;}},p=class extends Error{code;constructor(e,n="auth.json is invalid \u2014 please log in again"){super(n),this.name="AuthJsonValidationError",this.code=e;}},i=class extends s{constructor(e){let n=e.startsWith("ACCOUNT_BASE_URL")?"CREWX_ACCOUNT_BASE_URL":e.startsWith("ACCOUNT_ISSUER")?"CREWX_ACCOUNT_ISSUER":e==="ACCOUNT_TARGET_INVALID"?"CREWX_TARGET":e==="ACCOUNT_TARGET_MIXED"?"CREWX_ACCOUNT_BASE_URL/CREWX_MARKETPLACE_URL":e==="MARKETPLACE_DISABLED"?"CREWX_MARKETPLACE_DISABLED":"CREWX_MARKETPLACE_URL",r=e==="ACCOUNT_TARGET_MIXED"?`${n} must not mix loopback and public hosts \u2014 choose one account target`:e==="MARKETPLACE_DISABLED"?`${n} disables Marketplace access`:`${n} is missing or invalid \u2014 configure it and try again`;super(e,"configuration",void 0,r),this.name="AccountConfigurationError";}};var N="CREWX_ACCOUNT_BASE_URL",k="CREWX_ACCOUNT_ISSUER",O="CREWX_MARKETPLACE_URL",x="CREWX_TARGET",j="CREWX_MARKETPLACE_DISABLED",y=Object.freeze({accountBaseUrl:"https://app.sowonai.com",marketplaceUrl:"https://market.sowonai.com"}),R=Object.freeze({accountBaseUrl:"http://127.0.0.1:3030",marketplaceUrl:"http://127.0.0.1:4000"}),L=Object.freeze(["https://app.sowonai.com/auth/v1","https://auth.sowonai.com/auth/v1"]);function D(t,e,n=false){let r=t?.trim();if(!r)throw new i(e);try{let o=new URL(r);if(o.protocol!=="http:"&&o.protocol!=="https:"||o.username.length>0||o.password.length>0||o.hostname.length===0||o.search.length>0||o.hash.length>0||n&&o.pathname!=="/")throw new Error("invalid URL")}catch{throw new i(e)}return r.replace(/\/+$/,"")}function X(t){let e=t?.trim();if(!e)throw new i("ACCOUNT_ISSUER_INVALID");try{let n=new URL(e);if(n.protocol!=="http:"&&n.protocol!=="https:"||n.username.length>0||n.password.length>0||n.hostname.length===0||n.search.length>0||n.hash.length>0)throw new Error("invalid issuer")}catch{throw new i("ACCOUNT_ISSUER_INVALID")}return e}function P(t){let e=t[x];if(e===void 0)return "production";let n=e.trim();if(n==="local"||n==="production")return n;throw new i("ACCOUNT_TARGET_INVALID")}function q(t){let e=t[j]?.trim().toLowerCase();return e==="1"||e==="true"}function b(t){return t==="local"?R:y}function V(t=process.env){let e=P(t),n=t[N];return n!==void 0?D(n,"ACCOUNT_BASE_URL_INVALID",true):b(e).accountBaseUrl}function fe(t=process.env){let e=P(t);if(q(t))throw new i("MARKETPLACE_DISABLED");let n=t[O];return n!==void 0?D(n,"MARKETPLACE_URL_INVALID"):b(e).marketplaceUrl}function I(t=process.env){let e=t[k];return e===void 0?L:[X(e)]}function de(t=process.env){return I(t)[0]}function G(t,e,n,r=false){if(t===void 0)return e;try{return D(t,n,r)}catch{return t.trim()}}function Ae(t){let e=t[k];if(e===void 0)return L;try{return [X(e)]}catch{return [e.trim()]}}function W(t){if(t===null)return false;try{let e=new URL(t).hostname.toLowerCase();return e==="127.0.0.1"||e==="localhost"||e==="[::1]"||e==="::1"}catch{return false}}function _e(t,e){return e!==null&&t===y.accountBaseUrl&&e===y.marketplaceUrl?"production":e!==null&&t===R.accountBaseUrl&&e===R.marketplaceUrl?"local":"custom"}function F(t=process.env){let e,n=true;try{e=P(t);}catch{e="production",n=false;}let r=b(e),o=t[x]!==void 0&&n,c=t[N],m=t[O],u=q(t),d=G(c,r.accountBaseUrl,"ACCOUNT_BASE_URL_INVALID",true),S=u?null:G(m,r.marketplaceUrl,"MARKETPLACE_URL_INVALID");return {accountBaseUrl:d,marketplaceUrl:S,issuers:Ae(t),profile:_e(d,S),sources:{accountBaseUrl:c===void 0?o?"profile":"default":"env",marketplaceUrl:u?"disabled":m===void 0?o?"profile":"default":"env",issuer:t[k]===void 0?"default":"env"},mixed:S!==null&&W(d)!==W(S),marketplaceDisabled:u}}function ge(t=process.env){if(F(t).mixed)throw new i("ACCOUNT_TARGET_MIXED")}function J(t,e){return `${t.replace(/\/+$/,"")}/${e.replace(/^\/+/,"")}`}function U(){if(process.env.CREWX_HOME){let t=T__namespace.resolve(process.env.CREWX_HOME);try{return z__namespace.realpathSync(t)}catch(e){if(e instanceof Error&&"code"in e&&e.code==="ENOENT")return t;throw e}}return process.platform!=="win32"&&process.env.XDG_CONFIG_HOME?T__namespace.join(process.env.XDG_CONFIG_HOME,"crewx"):T__namespace.join($__namespace.homedir(),".crewx")}var ee="CREWX_TASK_TICKET_SECRET";function te(t={}){let e=t.workspaceDir??process.env.CREWX_WORKSPACE??process.cwd(),n=t.homeDir??U();return {workspace:T.join(e,".env"),home:T.join(n,".env")}}function Ee(t){try{return new Set(Object.keys(dotenv.parse(z.readFileSync(t))))}catch(e){if(e?.code==="ENOENT")return new Set;throw e}}function me(t){try{return dotenv.parse(z.readFileSync(t))}catch(e){if(e?.code==="ENOENT")return {};throw e}}function Te(t={}){let e=te(t);for(let n of [e.workspace,e.home]){let r=me(n);for(let[o,c]of Object.entries(r))o===ee||process.env[o]!==void 0||(process.env[o]=c);}}var se="auth.json",B=2,oe=["version","sub","email","access_token","refresh_token","expires_at","updated_at"];function h(t="auth.json is invalid \u2014 please log in again"){throw new p("AUTH_JSON_INVALID",t)}function Ue(){throw new p("AUTH_JSON_LEGACY","auth.json uses an unsupported legacy format \u2014 please log in again")}function ve(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Ne(t){try{return g(t),!0}catch{return false}}function g(t){if(!ve(t))return h();if(t.version===1)return Ue();if(t.version!==B)return h();let e=Object.keys(t);if(e.length!==oe.length||e.some(r=>!oe.includes(r))||typeof t.sub!="string"||t.sub.length===0||typeof t.email!="string"||t.email.length===0||typeof t.access_token!="string"||t.access_token.length===0||typeof t.refresh_token!="string"||t.refresh_token.length===0)return h();let n=t.expires_at;return typeof n!="number"||!Number.isSafeInteger(n)||n<0||typeof t.updated_at!="string"||t.updated_at.length===0||Number.isNaN(Date.parse(t.updated_at))?h():{version:B,sub:t.sub,email:t.email,access_token:t.access_token,refresh_token:t.refresh_token,expires_at:n,updated_at:t.updated_at}}function ie(t){let e;try{e=JSON.parse(t);}catch{return h()}return g(e)}function ce(t){return t??T.join(U(),se)}var A=class{configuredPath;constructor(e={}){this.configuredPath=typeof e=="string"?e:e.filePath;}path(){return ce(this.configuredPath)}read(){let e=this.path();if(!z.existsSync(e))return null;try{return ie(z.readFileSync(e,"utf8"))}catch(n){throw n instanceof p?n:new p("AUTH_JSON_INVALID")}}write(e){let n=g(e),r=this.path(),o=T.dirname(r);z.mkdirSync(o,{recursive:true,mode:448});let c=`${r}.tmp.${process.pid}.${crypto.randomUUID()}`;try{z.writeFileSync(c,JSON.stringify(n,null,2),{encoding:"utf8",mode:384}),z.chmodSync(c,384),z.renameSync(c,r),z.chmodSync(r,384);}catch{try{z.existsSync(c)&&z.unlinkSync(c);}catch{}throw new Error("Could not persist auth.json securely")}}clear(){let e=this.path();try{z.existsSync(e)&&z.unlinkSync(e);}catch{throw new Error("Could not clear auth.json")}}};function Oe(t){let e=new A({filePath:t}).read();if(!e)throw new l;return e}function xe(t,e){new A({filePath:e}).write(t);}function Le(t){new A({filePath:t}).clear();}var ue="/auth/v1/oauth/device/code",pe="/auth/v1/oauth/token",he="/auth/v1/oauth/revoke",v="crewx-cli",E="urn:ietf:params:oauth:grant-type:device_code";function a(t){return typeof t=="string"&&t.trim().length>0}function C(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)?t:null}function De(t){let e=C(t),n=e?.error??e?.code;if(typeof n=="string")return n.toLowerCase();let r=C(n),o=r?.code??r?.error;return typeof o=="string"?o.toLowerCase():void 0}function Pe(t){let e=C(t);if(!e||!a(e.device_code)||!a(e.user_code)||!a(e.verification_uri))throw new s("AUTH_RESPONSE_INVALID","protocol");let n=e.expires_in,r=e.interval;if(typeof n!="number"||!Number.isSafeInteger(n)||n<=0)throw new s("AUTH_RESPONSE_INVALID","protocol");if(e.verification_uri_complete!==void 0&&!a(e.verification_uri_complete))throw new s("AUTH_RESPONSE_INVALID","protocol");if(r!==void 0&&(typeof r!="number"||!Number.isSafeInteger(r)||r<0))throw new s("AUTH_RESPONSE_INVALID","protocol");let o={device_code:e.device_code,user_code:e.user_code,verification_uri:e.verification_uri,expires_in:n};return e.verification_uri_complete!==void 0&&(o.verification_uri_complete=e.verification_uri_complete),r!==void 0&&(o.interval=r),o}function be(t){let e=C(t),n=C(e?.account),r=e?.expires_in;if(!e||!a(e.access_token)||!a(e.refresh_token)||typeof r!="number"||!Number.isSafeInteger(r)||r<=0||!n||!a(n.sub)||!a(n.email))throw new s("AUTH_RESPONSE_INVALID","protocol");let o={access_token:e.access_token,refresh_token:e.refresh_token,expires_in:r,account:{sub:n.sub,email:n.email}};return typeof e.token_type=="string"&&e.token_type.length>0&&(o.token_type=e.token_type),typeof e.scope=="string"&&e.scope.length>0&&(o.scope=e.scope),o}var w=class{configuredBaseUrl;fetchImpl;timeoutMs;constructor(e={}){let n=typeof e=="string"?{baseUrl:e}:e;this.configuredBaseUrl=n.baseUrl===void 0?void 0:Ve(n.baseUrl),this.fetchImpl=n.fetch??n.fetchImpl,this.timeoutMs=n.timeoutMs??1e4;}baseUrl(){return this.configuredBaseUrl!==void 0?this.configuredBaseUrl:V()}signal(e){if(!(e<=0||typeof AbortSignal>"u"||typeof AbortSignal.timeout!="function"))return AbortSignal.timeout(e)}async request(e,n,r,o={}){let c=J(this.baseUrl(),e),m=this.fetchImpl??globalThis.fetch;if(typeof m!="function")throw new s("AUTH_NETWORK_ERROR","network");let u;try{u=await m(c,{...n,signal:n.signal??this.signal(o.timeoutMs??this.timeoutMs)});}catch{throw new s("AUTH_NETWORK_ERROR","network")}if(o.parseBody===false){if(!u.ok)throw ae(u.status,null,r);return}let d=null;try{d=await u.json();}catch{d=null;}if(!u.ok)throw ae(u.status,d,r);return d}async requestDeviceCode(){let e=new URLSearchParams;e.set("client_id",v);let n=await this.request(ue,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:e.toString()});return Pe(n)}async requestToken(e){Je(e);let n=new URLSearchParams;n.set("grant_type",e.grant_type),n.set("client_id",v),e.grant_type===E?n.set("device_code",e.device_code):n.set("refresh_token",e.refresh_token);let r=await this.request(pe,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:n.toString()},e);return be(r)}async exchangeDeviceCode(e){return this.requestToken({grant_type:E,device_code:e})}async refreshToken(e){return this.requestToken({grant_type:"refresh_token",refresh_token:e})}async deviceCode(){return this.requestDeviceCode()}async getDeviceCode(){return this.requestDeviceCode()}async token(e){return this.requestToken(e)}async getToken(e){return this.requestToken(e)}async refresh(e){return this.refreshToken(e)}async refreshAccessToken(e){return this.refreshToken(e)}async revokeToken(e){if(!a(e))throw new s("AUTH_INPUT_INVALID","protocol");let n=new URLSearchParams;n.set("token",e),n.set("token_type_hint","refresh_token"),n.set("client_id",v),await this.request(he,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:n.toString()},void 0,{parseBody:false,timeoutMs:3e3});}async revoke(e){return this.revokeToken(e)}};function Ve(t){if(typeof t!="string"||!t.trim())throw new i("ACCOUNT_BASE_URL_INVALID");try{let e=new URL(t.trim());if(e.protocol!=="http:"&&e.protocol!=="https:"||e.username.length>0||e.password.length>0||e.hostname.length===0||e.pathname!=="/"||e.search.length>0||e.hash.length>0)throw new Error("invalid URL")}catch{throw new i("ACCOUNT_BASE_URL_INVALID")}return t.trim().replace(/\/+$/,"")}function Je(t){if(!t||t.grant_type!==E&&t.grant_type!=="refresh_token"||t.grant_type===E&&!a(t.device_code)||t.grant_type==="refresh_token"&&!a(t.refresh_token))throw new s("AUTH_INPUT_INVALID","protocol")}function ae(t,e,n){let r=De(e);if(t>=500)return new s("AUTH_SERVER_ERROR","server",t);if(n?.grant_type==="refresh_token"&&(r==="invalid_grant"||t===401))return new s("INVALID_REFRESH_TOKEN","invalid_refresh",t);if(n?.grant_type===E){if(r==="authorization_pending")return new s("AUTHORIZATION_PENDING","pending",t);if(r==="slow_down")return new s("SLOW_DOWN","pending",t);if(r==="access_denied")return new s("ACCESS_DENIED","denied",t);if(r==="expired_token")return new s("EXPIRED_TOKEN","expired",t)}return new s("AUTH_HTTP_ERROR","http",t)}var K=class{client;store;refreshSkewSeconds;now;nowSecondsOverride;refreshPromise=null;constructor(e={},n){let r=Be(e)?e:void 0,o=r?{}:e;this.client=r??o.client??o.authClient??new w,this.store=o.store??o.storage??n??new A,this.refreshSkewSeconds=o.refreshSkewSeconds??60,this.now=o.now??(()=>Date.now()),this.nowSecondsOverride=o.nowSeconds;}getSession(){return this.readSession()}isLoggedIn(){return this.readSession()!==null}async getAccessToken(){let e=this.requireSession();return e.expires_at>this.epochSeconds()+this.refreshSkewSeconds?e.access_token:(await this.refreshSession(e)).access_token}async getValidAccessToken(){return this.getAccessToken()}async getToken(){return this.getAccessToken()}async refresh(){return this.refreshSession(this.requireSession())}async loginWithDeviceCode(e){let n=await this.client.exchangeDeviceCode(e);return this.persistTokenResponse(n)}async login(e){return this.loginWithDeviceCode(e)}async setSession(e){return this.persistTokenResponse(e)}clear(){this.store.clear();}async withAccessToken(e){return e(await this.getAccessToken())}readSession(){try{let e=this.store.read();if(e===null)return null;let n=g(e);return le(n.access_token,n.sub),n}catch(e){throw e instanceof p?new l:e}}requireSession(){let e=this.readSession();if(!e)throw new l;return e}epochSeconds(){return this.nowSecondsOverride?.()??Math.floor(this.now()/1e3)}refreshSession(e){if(this.refreshPromise)return this.refreshPromise;let n;return n=this.performRefresh(e).finally(()=>{this.refreshPromise===n&&(this.refreshPromise=null);}),this.refreshPromise=n,n}async performRefresh(e){try{let n=await this.client.refreshToken(e.refresh_token);return this.persistTokenResponse(n,e.sub)}catch(n){throw Me(n)?(this.store.clear(),new l):n}}persistTokenResponse(e,n){let r=e?.account;if(!e||typeof e.access_token!="string"||e.access_token.length===0||typeof e.refresh_token!="string"||e.refresh_token.length===0||!Number.isSafeInteger(e.expires_in)||e.expires_in<=0||!r||typeof r.sub!="string"||r.sub.length===0||typeof r.email!="string"||r.email.length===0)throw new f("AUTH_RESPONSE_INVALID","Account token response is malformed");if(n!==void 0&&r.sub!==n)throw new f("ACCOUNT_SUB_MISMATCH","Account subject changed during token refresh \u2014 please log in again");le(e.access_token,r.sub);let o=g({version:2,sub:r.sub,email:r.email,access_token:e.access_token,refresh_token:e.refresh_token,expires_at:this.epochSeconds()+e.expires_in,updated_at:new Date(this.now()).toISOString()});return this.store.write(o),o}};function Me(t){return t instanceof s?t.kind==="invalid_refresh":typeof t=="object"&&t!==null&&(t.kind==="invalid_refresh"||t.code==="INVALID_REFRESH_TOKEN")}function Be(t){return typeof t.exchangeDeviceCode=="function"&&typeof t.refreshToken=="function"}function le(t,e){let n=I(),r=He(t);if(!n.includes(r.iss))throw new f("ACCOUNT_ISSUER_MISMATCH","Access token issuer does not match the configured account issuer \u2014 please log in again");if(r.sub!==e)throw new f("ACCOUNT_SUB_MISMATCH","Access token subject does not match the account session \u2014 please log in again")}function He(t){if(typeof t!="string")throw H();let e=t.split(".");if(e.length!==3||e.some(n=>!/^[A-Za-z0-9_-]+$/.test(n)))throw H();try{let n=JSON.parse(Buffer.from(e[1],"base64url").toString("utf8"));if(typeof n!="object"||n===null||Array.isArray(n)||typeof n.iss!="string"||n.iss.length===0||typeof n.sub!="string"||n.sub.length===0)throw new Error("missing identity claims");return {iss:n.iss,sub:n.sub}}catch{throw H()}}function H(){return new f("ACCESS_TOKEN_INVALID","Access token identity could not be verified \u2014 please log in again")}
|
|
2
|
+
exports.ACCOUNT_BASE_URL_ENV=N;exports.ACCOUNT_ISSUER_ENV=k;exports.ACCOUNT_TARGET_ENV=x;exports.AUTH_JSON_FILENAME=se;exports.AUTH_JSON_VERSION=B;exports.AccountAuthError=s;exports.AccountConfigurationError=i;exports.AuthClient=w;exports.AuthClientError=s;exports.AuthError=s;exports.AuthJsonStore=A;exports.AuthJsonValidationError=p;exports.CREWX_TASK_TICKET_SECRET_ENV=ee;exports.DEFAULT_ACCEPTED_ISSUERS=L;exports.DEVICE_CODE_GRANT_TYPE=E;exports.DEVICE_CODE_PATH=ue;exports.LOCAL_TARGET=R;exports.LoginRequiredError=l;exports.MARKETPLACE_DISABLED_ENV=j;exports.MARKETPLACE_URL_ENV=O;exports.OAUTH_CLIENT_ID=v;exports.PRODUCTION_TARGET=y;exports.REVOKE_PATH=he;exports.SessionManager=K;exports.SessionManagerError=f;exports.TOKEN_PATH=pe;exports.appendEndpoint=J;exports.assertAccountTargetNotMixed=ge;exports.authJsonPath=ce;exports.clearAuthJson=Le;exports.isAuthJsonV2=Ne;exports.loadCrewxEnvFiles=Te;exports.parseAuthJson=ie;exports.readAuthJson=Oe;exports.readCrewxEnvFileKeys=Ee;exports.resolveAcceptedAccountIssuers=I;exports.resolveAccountBaseUrl=V;exports.resolveAccountIssuer=de;exports.resolveAccountTarget=F;exports.resolveCrewxEnvFilePaths=te;exports.resolveMarketplaceUrl=fe;exports.validateAuthJson=g;exports.writeAuthJson=xe;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { type OAuthTokenResponse } from './auth-client';
|
|
2
|
+
import { type AuthJsonV2 } from './auth-json';
|
|
3
|
+
export interface AuthSessionStore {
|
|
4
|
+
read(): AuthJsonV2 | null;
|
|
5
|
+
write(value: AuthJsonV2): void;
|
|
6
|
+
clear(): void;
|
|
7
|
+
}
|
|
8
|
+
export interface AccountAuthClient {
|
|
9
|
+
exchangeDeviceCode(deviceCode: string): Promise<OAuthTokenResponse>;
|
|
10
|
+
refreshToken(refreshToken: string): Promise<OAuthTokenResponse>;
|
|
11
|
+
}
|
|
12
|
+
export interface SessionManagerOptions {
|
|
13
|
+
client?: AccountAuthClient;
|
|
14
|
+
authClient?: AccountAuthClient;
|
|
15
|
+
store?: AuthSessionStore;
|
|
16
|
+
storage?: AuthSessionStore;
|
|
17
|
+
refreshSkewSeconds?: number;
|
|
18
|
+
now?: () => number;
|
|
19
|
+
nowSeconds?: () => number;
|
|
20
|
+
}
|
|
21
|
+
export type AuthJsonStorage = AuthSessionStore;
|
|
22
|
+
export declare class SessionManager {
|
|
23
|
+
private readonly client;
|
|
24
|
+
private readonly store;
|
|
25
|
+
private readonly refreshSkewSeconds;
|
|
26
|
+
private readonly now;
|
|
27
|
+
private readonly nowSecondsOverride?;
|
|
28
|
+
private refreshPromise;
|
|
29
|
+
constructor(options?: SessionManagerOptions | AccountAuthClient, store?: AuthSessionStore);
|
|
30
|
+
getSession(): AuthJsonV2 | null;
|
|
31
|
+
isLoggedIn(): boolean;
|
|
32
|
+
getAccessToken(): Promise<string>;
|
|
33
|
+
getValidAccessToken(): Promise<string>;
|
|
34
|
+
getToken(): Promise<string>;
|
|
35
|
+
refresh(): Promise<AuthJsonV2>;
|
|
36
|
+
loginWithDeviceCode(deviceCode: string): Promise<AuthJsonV2>;
|
|
37
|
+
login(deviceCode: string): Promise<AuthJsonV2>;
|
|
38
|
+
setSession(token: OAuthTokenResponse): Promise<AuthJsonV2>;
|
|
39
|
+
clear(): void;
|
|
40
|
+
withAccessToken<T>(callback: (accessToken: string) => Promise<T>): Promise<T>;
|
|
41
|
+
private readSession;
|
|
42
|
+
private requireSession;
|
|
43
|
+
private epochSeconds;
|
|
44
|
+
private refreshSession;
|
|
45
|
+
private performRefresh;
|
|
46
|
+
private persistTokenResponse;
|
|
47
|
+
}
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
export declare const PROMPT_PREPARATION_SLOW_THRESHOLD_MS = 3000;
|
|
2
|
+
export interface ActivityLogRenderedEntry {
|
|
3
|
+
entry: ActivityEntry;
|
|
4
|
+
newestIndex: number;
|
|
5
|
+
bodyLimitChars: number;
|
|
6
|
+
bodyCharsShown: number | null;
|
|
7
|
+
originalBodyChars: number | null;
|
|
8
|
+
}
|
|
1
9
|
export declare function checkStale(tool: string, input: string | null, taskCompletedAt?: string | null): 'ok' | 'stale' | 'unknown';
|
|
2
10
|
export interface ActivityEntry {
|
|
3
11
|
tool: string;
|
|
@@ -6,18 +14,63 @@ export interface ActivityEntry {
|
|
|
6
14
|
status: 'ok' | 'stale' | 'unknown';
|
|
7
15
|
reusable: boolean;
|
|
8
16
|
}
|
|
9
|
-
export
|
|
17
|
+
export type CountTokens = (text: string) => number;
|
|
18
|
+
export type ActivityLogOmissionReason = 'token_cap' | 'repository_limit';
|
|
19
|
+
export interface ActivityLogOmission {
|
|
20
|
+
reason: ActivityLogOmissionReason;
|
|
21
|
+
count: number;
|
|
22
|
+
message: string;
|
|
23
|
+
}
|
|
24
|
+
export interface ActivityLogTaskResult {
|
|
25
|
+
taskId: string;
|
|
26
|
+
taskDistance: number;
|
|
27
|
+
tokenCap: number;
|
|
28
|
+
tokenCount: number;
|
|
29
|
+
includedEntries: number;
|
|
30
|
+
omittedEntries: number;
|
|
31
|
+
totalEntries: number;
|
|
32
|
+
omissions: ActivityLogOmission[];
|
|
33
|
+
entries: ActivityLogRenderedEntry[];
|
|
34
|
+
activityLog: string;
|
|
35
|
+
readable?: false;
|
|
36
|
+
}
|
|
37
|
+
export interface ActivityLogByTaskResult {
|
|
10
38
|
threadId: string;
|
|
11
39
|
agentId: string;
|
|
12
40
|
lookback: number;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
41
|
+
activityLogTokenBudget: number;
|
|
42
|
+
baseEntryChars: number;
|
|
43
|
+
tasks: ActivityLogTaskResult[];
|
|
44
|
+
activityLogByTask: Map<string, string>;
|
|
45
|
+
}
|
|
46
|
+
export interface BuildActivityLogByTaskBudgetOptions {
|
|
47
|
+
threadId: string;
|
|
48
|
+
agentId: string;
|
|
49
|
+
lookback: number;
|
|
50
|
+
maxEntryChars?: number;
|
|
51
|
+
activityLogTokenBudget: number;
|
|
52
|
+
countTokens: CountTokens;
|
|
53
|
+
repositoryEntryLimit?: number;
|
|
54
|
+
currentTaskId?: string;
|
|
16
55
|
}
|
|
17
|
-
export
|
|
56
|
+
export interface BuildActivityLogByTaskOptions {
|
|
18
57
|
threadId: string;
|
|
19
58
|
agentId: string;
|
|
20
59
|
lookback: number;
|
|
21
60
|
maxEntryChars?: number;
|
|
22
61
|
decayRate?: number;
|
|
23
|
-
|
|
62
|
+
activityLogTokenBudget?: number;
|
|
63
|
+
countTokens?: CountTokens;
|
|
64
|
+
repositoryEntryLimit?: number;
|
|
65
|
+
currentTaskId?: string;
|
|
66
|
+
}
|
|
67
|
+
export interface ActivityLogResult {
|
|
68
|
+
threadId: string;
|
|
69
|
+
agentId: string;
|
|
70
|
+
lookback: number;
|
|
71
|
+
entries: ActivityEntry[];
|
|
72
|
+
totalEntries: number;
|
|
73
|
+
truncated: boolean;
|
|
74
|
+
}
|
|
75
|
+
export declare function buildActivityLogByTaskResult(opts: BuildActivityLogByTaskBudgetOptions): ActivityLogByTaskResult;
|
|
76
|
+
export declare function buildActivityLogByTask(opts: BuildActivityLogByTaskOptions): Map<string, string>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { AgentConfig } from '../types';
|
|
2
|
+
export interface AgentListFilters {
|
|
3
|
+
role?: string;
|
|
4
|
+
team?: string;
|
|
5
|
+
provider?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface AgentListSnapshot {
|
|
8
|
+
agents: AgentConfig[];
|
|
9
|
+
total: number;
|
|
10
|
+
configPath: string | null;
|
|
11
|
+
}
|
|
12
|
+
export interface AgentListFormatOptions {
|
|
13
|
+
agents: readonly AgentConfig[];
|
|
14
|
+
total: number;
|
|
15
|
+
isFiltered: boolean;
|
|
16
|
+
configPath?: string | null;
|
|
17
|
+
}
|
|
18
|
+
export declare function filterAgentConfigs(agents: readonly AgentConfig[], filters: AgentListFilters): AgentConfig[];
|
|
19
|
+
export declare function formatAgentList(options: AgentListFormatOptions): string;
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import type { UiContentMediaType } from './content-media-types.js';
|
|
2
|
+
export type JsonObject = Record<string, unknown>;
|
|
3
|
+
export type JsonSchema = Readonly<{
|
|
4
|
+
type: 'object';
|
|
5
|
+
properties: Readonly<Record<string, unknown>>;
|
|
6
|
+
required: readonly string[];
|
|
7
|
+
additionalProperties: false;
|
|
8
|
+
}>;
|
|
9
|
+
export type ToolResult = void | JsonObject | Promise<void | JsonObject>;
|
|
10
|
+
export interface AppDefinition {
|
|
11
|
+
readonly manifestVersion: 2;
|
|
12
|
+
readonly pluginId: string;
|
|
13
|
+
readonly definitionId: string;
|
|
14
|
+
readonly version: number;
|
|
15
|
+
readonly name: string;
|
|
16
|
+
readonly description: string;
|
|
17
|
+
readonly icon?: string;
|
|
18
|
+
readonly tone?: string;
|
|
19
|
+
readonly entry: string;
|
|
20
|
+
readonly initialState: Readonly<{
|
|
21
|
+
path: string;
|
|
22
|
+
}>;
|
|
23
|
+
readonly dataPaths?: readonly string[];
|
|
24
|
+
readonly surfaces: readonly string[];
|
|
25
|
+
readonly size?: Readonly<Record<string, number>>;
|
|
26
|
+
readonly stateProjection: Readonly<{
|
|
27
|
+
allow: readonly string[];
|
|
28
|
+
}>;
|
|
29
|
+
}
|
|
30
|
+
export interface ToolContentInput {
|
|
31
|
+
readonly mediaType: UiContentMediaType;
|
|
32
|
+
readonly required?: boolean;
|
|
33
|
+
}
|
|
34
|
+
export interface ToolContentOutput {
|
|
35
|
+
readonly mediaType: UiContentMediaType;
|
|
36
|
+
readonly range?: boolean;
|
|
37
|
+
}
|
|
38
|
+
export interface ToolContentDeclaration {
|
|
39
|
+
readonly in?: ToolContentInput;
|
|
40
|
+
readonly out?: ToolContentOutput;
|
|
41
|
+
}
|
|
42
|
+
export interface ContentRangeRequest {
|
|
43
|
+
readonly startLine: number;
|
|
44
|
+
readonly lineCount: number;
|
|
45
|
+
}
|
|
46
|
+
export interface ContentRange extends ContentRangeRequest {
|
|
47
|
+
readonly totalLines: number;
|
|
48
|
+
}
|
|
49
|
+
export interface ToolContent {
|
|
50
|
+
readonly in?: {
|
|
51
|
+
readonly text: string;
|
|
52
|
+
};
|
|
53
|
+
readonly out?: {
|
|
54
|
+
readonly range?: ContentRangeRequest;
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
export interface ToolOptions {
|
|
58
|
+
readonly name: string;
|
|
59
|
+
readonly description: string;
|
|
60
|
+
readonly inputSchema: JsonSchema;
|
|
61
|
+
readonly capability?: string;
|
|
62
|
+
readonly confirmation?: string;
|
|
63
|
+
readonly mutation?: boolean;
|
|
64
|
+
readonly dataInputs?: readonly string[];
|
|
65
|
+
readonly resultProjection?: Readonly<{
|
|
66
|
+
allow: readonly string[];
|
|
67
|
+
}>;
|
|
68
|
+
readonly content?: ToolContentDeclaration;
|
|
69
|
+
}
|
|
70
|
+
export interface AppContext {
|
|
71
|
+
readonly instanceId: string;
|
|
72
|
+
readonly threadId: string | null;
|
|
73
|
+
readonly actor: 'user' | 'agent';
|
|
74
|
+
readonly requestId: string;
|
|
75
|
+
readonly nowMs: number;
|
|
76
|
+
}
|
|
77
|
+
export interface AppRuntimeOptions<State extends JsonObject = JsonObject> {
|
|
78
|
+
readonly state?: State;
|
|
79
|
+
readonly workspaceRoot: string;
|
|
80
|
+
readonly context?: AppContext;
|
|
81
|
+
}
|
|
82
|
+
export type AppFailureOutcome = 'failed' | 'rejected';
|
|
83
|
+
export interface AppErrorMapping {
|
|
84
|
+
readonly code: string;
|
|
85
|
+
readonly detail: string | null;
|
|
86
|
+
readonly outcome?: AppFailureOutcome;
|
|
87
|
+
}
|
|
88
|
+
export interface AppErrorOptions {
|
|
89
|
+
readonly outcome?: AppFailureOutcome;
|
|
90
|
+
}
|
|
91
|
+
export interface AppErrorContext {
|
|
92
|
+
readonly input: unknown;
|
|
93
|
+
readonly state: unknown;
|
|
94
|
+
}
|
|
95
|
+
export type DeepReadonly<T> = T extends (...args: never[]) => unknown ? T : T extends readonly (infer Item)[] ? readonly DeepReadonly<Item>[] : T extends object ? {
|
|
96
|
+
readonly [Key in keyof T]: DeepReadonly<T[Key]>;
|
|
97
|
+
} : T;
|
|
98
|
+
export declare class AppError extends Error {
|
|
99
|
+
readonly code: string;
|
|
100
|
+
readonly detail: string | null;
|
|
101
|
+
readonly outcome: AppFailureOutcome;
|
|
102
|
+
constructor(code: string, detail?: string | null, options?: AppErrorOptions);
|
|
103
|
+
}
|
|
104
|
+
export declare function normalizeFailureOutcome(value: unknown): AppFailureOutcome;
|
|
105
|
+
export declare class CrewXApp<State extends JsonObject = JsonObject> {
|
|
106
|
+
static readonly devtools: {
|
|
107
|
+
readonly log: boolean;
|
|
108
|
+
} | undefined;
|
|
109
|
+
private currentState;
|
|
110
|
+
private stateWasSet;
|
|
111
|
+
private answerBody;
|
|
112
|
+
private answerRange;
|
|
113
|
+
private readonly callContext;
|
|
114
|
+
readonly workspaceRoot: string;
|
|
115
|
+
constructor(options?: AppRuntimeOptions<State>);
|
|
116
|
+
get context(): AppContext;
|
|
117
|
+
get state(): DeepReadonly<State>;
|
|
118
|
+
get didSetState(): boolean;
|
|
119
|
+
setState(next: State): void;
|
|
120
|
+
get didSetContent(): boolean;
|
|
121
|
+
get producedContent(): {
|
|
122
|
+
readonly body: Uint8Array;
|
|
123
|
+
readonly range?: ContentRange;
|
|
124
|
+
} | undefined;
|
|
125
|
+
setContent(body: string | Uint8Array, range?: ContentRange): void;
|
|
126
|
+
emptyState(): State;
|
|
127
|
+
validate(_actionId: string, _input: JsonObject, _state: JsonObject): void | Promise<void>;
|
|
128
|
+
mapError(_error: unknown): AppErrorMapping;
|
|
129
|
+
errorState(code: string, detail: string | null, context: AppErrorContext): State;
|
|
130
|
+
}
|
|
131
|
+
export interface ToolDeclaration {
|
|
132
|
+
readonly methodName: string;
|
|
133
|
+
readonly options: ToolOptions;
|
|
134
|
+
}
|
|
135
|
+
export type CrewXAppConstructor = (new (options: AppRuntimeOptions) => CrewXApp) & {
|
|
136
|
+
readonly devtools?: {
|
|
137
|
+
readonly log?: boolean;
|
|
138
|
+
};
|
|
139
|
+
readonly definition: AppDefinition;
|
|
140
|
+
readonly [key: string]: unknown;
|
|
141
|
+
};
|
|
142
|
+
type DecoratedMethod<This, Input extends object, Result extends ToolResult> = (this: This, input: Input, content: ToolContent) => Result;
|
|
143
|
+
export declare function Tool(options: ToolOptions): <This, Input extends object, Result extends ToolResult>(_method: DecoratedMethod<This, Input, Result>, context: ClassMethodDecoratorContext<This, DecoratedMethod<This, Input, Result>>) => void;
|
|
144
|
+
export declare function getToolDeclarations(appClass: CrewXAppConstructor): ToolDeclaration[];
|
|
145
|
+
export declare function generateToolDeclarations(appClass: CrewXAppConstructor): JsonObject[];
|
|
146
|
+
export declare function generateManifest(appClass: CrewXAppConstructor, backendCommand: readonly string[]): JsonObject;
|
|
147
|
+
export declare function isPlainRecord(value: unknown): value is JsonObject;
|
|
148
|
+
export {};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare const SKILL_BACKEND_ENV_NAMES: readonly ["CREWX_APP_INSTANCE_ID", "CREWX_THREAD_ID"];
|
|
2
|
+
export type SkillBackendEnvName = (typeof SKILL_BACKEND_ENV_NAMES)[number];
|
|
3
|
+
export declare function isSkillBackendEnv(value: unknown): value is readonly SkillBackendEnvName[];
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { JsonObject } from './app.js';
|
|
2
|
+
export interface AppEntryOptions {
|
|
3
|
+
readonly sanitize?: (value: unknown) => unknown;
|
|
4
|
+
readonly emptyState?: JsonObject;
|
|
5
|
+
readonly inputFd?: number;
|
|
6
|
+
}
|
|
7
|
+
export declare function runAppEntry(importApp: () => Promise<unknown>, options?: AppEntryOptions): Promise<void>;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { ContentRange, ContentRangeRequest, JsonObject } from './app.js';
|
|
2
|
+
import type { UiContentMediaType } from './protocol.js';
|
|
3
|
+
export declare const V1_MAX_INPUT_BYTES: number;
|
|
4
|
+
export declare const MAX_REQUEST_BYTES: number;
|
|
5
|
+
export type RequestFrame = {
|
|
6
|
+
readonly kind: 'v1';
|
|
7
|
+
readonly value: unknown;
|
|
8
|
+
} | {
|
|
9
|
+
readonly kind: 'v2';
|
|
10
|
+
readonly header: JsonObject;
|
|
11
|
+
readonly body: Uint8Array;
|
|
12
|
+
} | {
|
|
13
|
+
readonly kind: 'invalid';
|
|
14
|
+
};
|
|
15
|
+
export declare function readStdinBytes(fd: number, maxBytes: number): Uint8Array | undefined;
|
|
16
|
+
export declare function readRequestFrame(fd: number): RequestFrame;
|
|
17
|
+
export declare function parseRequestFrame(bytes: Uint8Array | undefined): RequestFrame;
|
|
18
|
+
export interface ContentRequest {
|
|
19
|
+
readonly in?: {
|
|
20
|
+
readonly mediaType: UiContentMediaType;
|
|
21
|
+
readonly text: string;
|
|
22
|
+
};
|
|
23
|
+
readonly out?: {
|
|
24
|
+
readonly mediaType: UiContentMediaType;
|
|
25
|
+
readonly range?: ContentRangeRequest;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
export interface VerifiedFrame {
|
|
29
|
+
readonly actionId: string;
|
|
30
|
+
readonly input: JsonObject;
|
|
31
|
+
readonly state: JsonObject;
|
|
32
|
+
readonly content: ContentRequest;
|
|
33
|
+
}
|
|
34
|
+
export interface FrameFailure {
|
|
35
|
+
readonly code: string;
|
|
36
|
+
readonly outcome: 'failed' | 'rejected';
|
|
37
|
+
}
|
|
38
|
+
export declare function verifyRequestFrame(header: JsonObject, body: Uint8Array): VerifiedFrame | FrameFailure;
|
|
39
|
+
export declare function isFrameFailure(value: VerifiedFrame | FrameFailure): value is FrameFailure;
|
|
40
|
+
export interface DeclaredContent {
|
|
41
|
+
readonly in?: {
|
|
42
|
+
readonly mediaType: UiContentMediaType;
|
|
43
|
+
readonly required?: boolean;
|
|
44
|
+
};
|
|
45
|
+
readonly out?: {
|
|
46
|
+
readonly mediaType: UiContentMediaType;
|
|
47
|
+
readonly range?: boolean;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
export declare function checkAgainstDeclaration(declared: DeclaredContent | undefined, request: ContentRequest): FrameFailure | undefined;
|
|
51
|
+
export interface AnswerContent {
|
|
52
|
+
readonly body: Uint8Array;
|
|
53
|
+
readonly range?: ContentRange;
|
|
54
|
+
}
|
|
55
|
+
export declare function encodeResponseFrame(header: JsonObject, answer?: AnswerContent): Uint8Array;
|
|
56
|
+
export declare function answerLimitFailure(answer: AnswerContent): FrameFailure | undefined;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { AppError, CrewXApp, Tool, generateManifest, generateToolDeclarations, getToolDeclarations, } from './app.js';
|
|
2
|
+
export type { AppContext, AppDefinition, AppErrorContext, AppErrorMapping, AppErrorOptions, AppFailureOutcome, AppRuntimeOptions, ContentRange, ContentRangeRequest, CrewXAppConstructor, DeepReadonly, JsonObject, JsonSchema, ToolContent, ToolContentDeclaration, ToolContentInput, ToolContentOutput, ToolDeclaration, ToolOptions, ToolResult, } from './app.js';
|
|
3
|
+
export { readAppContext } from './context.js';
|
|
4
|
+
export { APP_TOOLS_FILE, APP_TOOLS_SCHEMA_VERSION, APP_TOOL_ENTRY } from './tool-mode.js';
|
|
5
|
+
export { SKILL_BACKEND_ENV_NAMES, isSkillBackendEnv } from './backend-env.js';
|
|
6
|
+
export type { SkillBackendEnvName } from './backend-env.js';
|
|
7
|
+
export { executeAppRequest, runSkillApp } from './runtime.js';
|
|
8
|
+
export type { AppFailureInfo, RunSkillAppOptions } from './runtime.js';
|
|
9
|
+
export { runAppEntry } from './entry.js';
|
|
10
|
+
export type { AppEntryOptions } from './entry.js';
|