@crowdedkingdoms/crowdyjs 15.12.1 → 16.0.0-dev.1
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/MIGRATION.md +55 -0
- package/README.md +67 -41
- package/dist/client.d.ts +1 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +3 -0
- package/dist/crowdy-client.d.ts +2 -3
- package/dist/crowdy-client.d.ts.map +1 -1
- package/dist/crowdy-client.js +9 -11
- package/dist/crowdy-dsh/bridge.d.ts +156 -0
- package/dist/crowdy-dsh/bridge.d.ts.map +1 -0
- package/dist/crowdy-dsh/bridge.js +523 -0
- package/dist/crowdy-dsh/index.d.ts +11 -0
- package/dist/crowdy-dsh/index.d.ts.map +1 -0
- package/dist/crowdy-dsh/index.js +10 -0
- package/dist/crowdy-dsh/pane.d.ts +64 -0
- package/dist/crowdy-dsh/pane.d.ts.map +1 -0
- package/dist/crowdy-dsh/pane.js +247 -0
- package/dist/crowdy-dsh/protocol.d.ts +249 -0
- package/dist/crowdy-dsh/protocol.d.ts.map +1 -0
- package/dist/crowdy-dsh/protocol.js +39 -0
- package/dist/crowdy-dsh/transport.d.ts +66 -0
- package/dist/crowdy-dsh/transport.d.ts.map +1 -0
- package/dist/crowdy-dsh/transport.js +88 -0
- package/dist/crowdy-studio/controller.d.ts +8 -0
- package/dist/crowdy-studio/controller.d.ts.map +1 -1
- package/dist/crowdy-studio/controller.js +33 -1
- package/dist/crowdy-studio/dom-shell.d.ts +21 -4
- package/dist/crowdy-studio/dom-shell.d.ts.map +1 -1
- package/dist/crowdy-studio/dom-shell.js +32 -17
- package/dist/crowdy-studio/embed/index.d.ts +1 -1
- package/dist/crowdy-studio/embed/index.d.ts.map +1 -1
- package/dist/crowdy-studio/embed/panel.d.ts +18 -18
- package/dist/crowdy-studio/embed/panel.d.ts.map +1 -1
- package/dist/crowdy-studio/embed/panel.js +7 -21
- package/dist/crowdy-studio/index.d.ts +2 -3
- package/dist/crowdy-studio/index.d.ts.map +1 -1
- package/dist/crowdy-studio/index.js +1 -2
- package/dist/crowdy-studio/mount.d.ts +29 -14
- package/dist/crowdy-studio/mount.d.ts.map +1 -1
- package/dist/crowdy-studio/mount.js +39 -126
- package/dist/crowdy-studio/styles.d.ts +1 -1
- package/dist/crowdy-studio/styles.d.ts.map +1 -1
- package/dist/crowdy-studio/styles.js +5 -0
- package/dist/default-origin.d.ts +6 -6
- package/dist/default-origin.d.ts.map +1 -1
- package/dist/default-origin.js +6 -6
- package/dist/generated/graphql.d.ts +76 -2438
- package/dist/generated/graphql.d.ts.map +1 -1
- package/dist/generated/graphql.js +0 -50
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/kit/npcs.d.ts.map +1 -1
- package/dist/kit/social.d.ts.map +1 -1
- package/dist/{crowdy-agent/errors.d.ts → player-host/agent-errors.d.ts} +1 -1
- package/dist/player-host/agent-errors.d.ts.map +1 -0
- package/dist/player-host/agent-types.d.ts +18 -0
- package/dist/player-host/agent-types.d.ts.map +1 -0
- package/dist/player-host/agent-types.js +7 -0
- package/dist/player-host/index.d.ts +12 -4
- package/dist/player-host/index.d.ts.map +1 -1
- package/dist/player-host/index.js +11 -4
- package/dist/{crowdy-agent/schema.d.ts → player-host/json-schema.d.ts} +1 -1
- package/dist/player-host/json-schema.d.ts.map +1 -0
- package/dist/{crowdy-agent/schema.js → player-host/json-schema.js} +1 -1
- package/dist/player-host/schemas.d.ts +1 -1
- package/dist/player-host/schemas.d.ts.map +1 -1
- package/dist/player-host/schemas.js +2 -2
- package/dist/player-host/types.d.ts +2 -2
- package/dist/player-host/types.d.ts.map +1 -1
- package/package.json +5 -7
- package/dist/crowdy-agent/browser-dispatcher.d.ts +0 -41
- package/dist/crowdy-agent/browser-dispatcher.d.ts.map +0 -1
- package/dist/crowdy-agent/browser-dispatcher.js +0 -264
- package/dist/crowdy-agent/controller.d.ts +0 -152
- package/dist/crowdy-agent/controller.d.ts.map +0 -1
- package/dist/crowdy-agent/controller.js +0 -1289
- package/dist/crowdy-agent/errors.d.ts.map +0 -1
- package/dist/crowdy-agent/graphql-transport.d.ts +0 -154
- package/dist/crowdy-agent/graphql-transport.d.ts.map +0 -1
- package/dist/crowdy-agent/graphql-transport.js +0 -854
- package/dist/crowdy-agent/index.d.ts +0 -17
- package/dist/crowdy-agent/index.d.ts.map +0 -1
- package/dist/crowdy-agent/index.js +0 -16
- package/dist/crowdy-agent/registry.d.ts +0 -29
- package/dist/crowdy-agent/registry.d.ts.map +0 -1
- package/dist/crowdy-agent/registry.js +0 -281
- package/dist/crowdy-agent/schema.d.ts.map +0 -1
- package/dist/crowdy-agent/session-resume.d.ts +0 -24
- package/dist/crowdy-agent/session-resume.d.ts.map +0 -1
- package/dist/crowdy-agent/session-resume.js +0 -76
- package/dist/crowdy-agent/studio-tools.d.ts +0 -15
- package/dist/crowdy-agent/studio-tools.d.ts.map +0 -1
- package/dist/crowdy-agent/studio-tools.js +0 -280
- package/dist/crowdy-agent/tool-descriptors.d.ts +0 -4
- package/dist/crowdy-agent/tool-descriptors.d.ts.map +0 -1
- package/dist/crowdy-agent/tool-descriptors.js +0 -1049
- package/dist/crowdy-agent/transport.d.ts +0 -152
- package/dist/crowdy-agent/transport.d.ts.map +0 -1
- package/dist/crowdy-agent/transport.js +0 -27
- package/dist/crowdy-agent/types.d.ts +0 -328
- package/dist/crowdy-agent/types.d.ts.map +0 -1
- package/dist/crowdy-agent/types.js +0 -37
- package/dist/crowdy-studio/agent-dom-shell.d.ts +0 -68
- package/dist/crowdy-studio/agent-dom-shell.d.ts.map +0 -1
- package/dist/crowdy-studio/agent-dom-shell.js +0 -418
- package/dist/player-host/control-banner.d.ts +0 -40
- package/dist/player-host/control-banner.d.ts.map +0 -1
- package/dist/player-host/control-banner.js +0 -252
- package/dist/player-host/control-gate.d.ts +0 -77
- package/dist/player-host/control-gate.d.ts.map +0 -1
- package/dist/player-host/control-gate.js +0 -197
- package/dist/player-host/lease-manager.d.ts +0 -66
- package/dist/player-host/lease-manager.d.ts.map +0 -1
- package/dist/player-host/lease-manager.js +0 -428
- package/dist/player-host/tools.d.ts +0 -13
- package/dist/player-host/tools.d.ts.map +0 -1
- package/dist/player-host/tools.js +0 -79
- /package/dist/{crowdy-agent/errors.js → player-host/agent-errors.js} +0 -0
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { CrowdyAgentToolRegistry } from './registry.js';
|
|
2
|
-
/** Frozen minimum registry for `crowdy.agent-tools/1`. */
|
|
3
|
-
export declare const CROWDY_AGENT_TOOL_REGISTRY_V1: CrowdyAgentToolRegistry;
|
|
4
|
-
export declare const CROWDY_AGENT_REGISTRY_V1: CrowdyAgentToolRegistry;
|
|
5
|
-
export { CrowdyAgentBrowserToolDispatcher, type CrowdyAgentBrowserDispatcherOptionsV1, type CrowdyAgentBrowserToolContextV1, type CrowdyAgentBrowserToolHandlerV1, type CrowdyAgentBrowserToolHandlersV1, } from './browser-dispatcher.js';
|
|
6
|
-
export { CrowdyStudioAgentController, CrowdyStudioAgentController as CrowdyStudioAgentClient, type CrowdyStudioAgentConnectionState, type CrowdyStudioAgentControllerOptionsV1, type CrowdyStudioAgentStateV1, } from './controller.js';
|
|
7
|
-
export { AGENT_SESSION_EMPTYISH_LAST_SEQ, agentSessionMemoryKey, pickResumableAgentSession, type AgentSessionResumeBinding, type StudioSessionMemory, } from './session-resume.js';
|
|
8
|
-
export { CrowdyAgentGraphQLTransport, type CrowdyAgentGraphQLSubscriptionClient, type CrowdyAgentGraphQLTransportOptions, } from './graphql-transport.js';
|
|
9
|
-
export { CROWDY_AGENT_ERROR_CODES, CrowdyAgentError, CrowdyAgentOutcomeUnknownError, toAgentError, type AgentErrorV1, type CrowdyAgentErrorCode, } from './errors.js';
|
|
10
|
-
export { FORBIDDEN_AGENT_TOOL_SURFACES, CrowdyAgentToolRegistry, isDescriptorDigest, type CrowdyAgentRegistryFilter, } from './registry.js';
|
|
11
|
-
export { FORBIDDEN_AGENT_AUTHORITY_FIELDS, assertBoundedJsonSchema, canonicalJson, deepFreeze, digestCanonicalJson, isDecimalString, sha256Digest, validateJsonSchemaValue, type JsonPrimitive, type JsonSchema, type JsonSchemaArray, type JsonSchemaBoolean, type JsonSchemaNull, type JsonSchemaNumber, type JsonSchemaObject, type JsonSchemaString, type JsonSchemaUnion, type JsonSchemaValidationOptions, } from './schema.js';
|
|
12
|
-
export { CROWDY_AGENT_TOOL_DESCRIPTORS_V1 } from './tool-descriptors.js';
|
|
13
|
-
export { createCrowdyStudioAgentTools, crowdyStudioAgentProjectTargets, type CrowdyStudioAgentToolsOptionsV1, } from './studio-tools.js';
|
|
14
|
-
export { CROWDY_AGENT_GRAPHQL_OPERATIONS_V1, type CrowdyAgentAttachResultV1, type CrowdyAgentConnectionV1, type CrowdyAgentCreateSessionInputV1, type CrowdyAgentEdgeV1, type CrowdyAgentEventSubscriptionHandlersV1, type CrowdyAgentEventSubscriptionV1, type CrowdyAgentHistoryPageV1, type CrowdyAgentPageInfoV1, type CrowdyStudioAgentTransportV1, } from './transport.js';
|
|
15
|
-
export { CROWDY_AGENT_EVENT_TYPES } from './types.js';
|
|
16
|
-
export type { CrowdyAgentApprovalPolicy, CrowdyAgentApprovalStatus, CrowdyAgentApprovalV1, CrowdyAgentBudgetDimensionV1, CrowdyAgentBudgetV1, CrowdyAgentHeartbeatV1, CrowdyAgentCheckpointFileV1, CrowdyAgentCheckpointV1, CrowdyAgentEventPayloadMap, CrowdyAgentEventType, CrowdyAgentEventV1, CrowdyAgentIdempotencyClass, CrowdyAgentLeaseStatus, CrowdyAgentLeaseV1, CrowdyAgentMessageV1, CrowdyAgentMode, CrowdyAgentPreemptionReason, CrowdyAgentRedactionAction, CrowdyAgentRedactionRuleV1, CrowdyAgentRegisteredToolV1, CrowdyAgentRunStatus, CrowdyAgentRunV1, CrowdyAgentScopeRequirementV1, CrowdyAgentSessionStatus, CrowdyAgentSessionV1, CrowdyAgentToolCallStatus, CrowdyAgentToolCallAckV1, CrowdyAgentToolDescriptorV1, CrowdyAgentToolExecutor, CrowdyAgentToolInvocationV1, CrowdyAgentToolResultStatus, CrowdyAgentToolResultV1, CrowdyAgentToolRisk, CrowdyAgentToolTimelineItemV1, } from './types.js';
|
|
17
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/crowdy-agent/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAGxD,0DAA0D;AAC1D,eAAO,MAAM,6BAA6B,yBAEzC,CAAC;AACF,eAAO,MAAM,wBAAwB,yBAAgC,CAAC;AAEtE,OAAO,EACL,gCAAgC,EAChC,KAAK,qCAAqC,EAC1C,KAAK,+BAA+B,EACpC,KAAK,+BAA+B,EACpC,KAAK,gCAAgC,GACtC,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,2BAA2B,EAC3B,2BAA2B,IAAI,uBAAuB,EACtD,KAAK,gCAAgC,EACrC,KAAK,oCAAoC,EACzC,KAAK,wBAAwB,GAC9B,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,+BAA+B,EAC/B,qBAAqB,EACrB,yBAAyB,EACzB,KAAK,yBAAyB,EAC9B,KAAK,mBAAmB,GACzB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,2BAA2B,EAC3B,KAAK,oCAAoC,EACzC,KAAK,kCAAkC,GACxC,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,wBAAwB,EACxB,gBAAgB,EAChB,8BAA8B,EAC9B,YAAY,EACZ,KAAK,YAAY,EACjB,KAAK,oBAAoB,GAC1B,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,6BAA6B,EAC7B,uBAAuB,EACvB,kBAAkB,EAClB,KAAK,yBAAyB,GAC/B,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,gCAAgC,EAChC,uBAAuB,EACvB,aAAa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,MAAM,YAAY,CAAC"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { CrowdyAgentToolRegistry } from './registry.js';
|
|
2
|
-
import { CROWDY_AGENT_TOOL_DESCRIPTORS_V1 } from './tool-descriptors.js';
|
|
3
|
-
/** Frozen minimum registry for `crowdy.agent-tools/1`. */
|
|
4
|
-
export const CROWDY_AGENT_TOOL_REGISTRY_V1 = new CrowdyAgentToolRegistry(CROWDY_AGENT_TOOL_DESCRIPTORS_V1);
|
|
5
|
-
export const CROWDY_AGENT_REGISTRY_V1 = CROWDY_AGENT_TOOL_REGISTRY_V1;
|
|
6
|
-
export { CrowdyAgentBrowserToolDispatcher, } from './browser-dispatcher.js';
|
|
7
|
-
export { CrowdyStudioAgentController, CrowdyStudioAgentController as CrowdyStudioAgentClient, } from './controller.js';
|
|
8
|
-
export { AGENT_SESSION_EMPTYISH_LAST_SEQ, agentSessionMemoryKey, pickResumableAgentSession, } from './session-resume.js';
|
|
9
|
-
export { CrowdyAgentGraphQLTransport, } from './graphql-transport.js';
|
|
10
|
-
export { CROWDY_AGENT_ERROR_CODES, CrowdyAgentError, CrowdyAgentOutcomeUnknownError, toAgentError, } from './errors.js';
|
|
11
|
-
export { FORBIDDEN_AGENT_TOOL_SURFACES, CrowdyAgentToolRegistry, isDescriptorDigest, } from './registry.js';
|
|
12
|
-
export { FORBIDDEN_AGENT_AUTHORITY_FIELDS, assertBoundedJsonSchema, canonicalJson, deepFreeze, digestCanonicalJson, isDecimalString, sha256Digest, validateJsonSchemaValue, } from './schema.js';
|
|
13
|
-
export { CROWDY_AGENT_TOOL_DESCRIPTORS_V1 } from './tool-descriptors.js';
|
|
14
|
-
export { createCrowdyStudioAgentTools, crowdyStudioAgentProjectTargets, } from './studio-tools.js';
|
|
15
|
-
export { CROWDY_AGENT_GRAPHQL_OPERATIONS_V1, } from './transport.js';
|
|
16
|
-
export { CROWDY_AGENT_EVENT_TYPES } from './types.js';
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import type { CrowdyAgentMode, CrowdyAgentRegisteredToolV1, CrowdyAgentToolDescriptorV1, CrowdyAgentToolExecutor } from './types.js';
|
|
2
|
-
/** Names whose presence would create ambient or arbitrary authority. */
|
|
3
|
-
export declare const FORBIDDEN_AGENT_TOOL_SURFACES: readonly ["graphql", "fetch", "http", "url", "socket", "shell", "process", "filesystem", "dom", "keyboard", "mouse", "pointer", "host_call", "playercodebroker", "udp", "token", "cookie", "storage", "devtools", "database", "buddy"];
|
|
4
|
-
export interface CrowdyAgentRegistryFilter {
|
|
5
|
-
readonly mode?: CrowdyAgentMode;
|
|
6
|
-
readonly executor?: CrowdyAgentToolExecutor;
|
|
7
|
-
/** Effective scopes filter descriptors; it never grants a scope. */
|
|
8
|
-
readonly availableScopes?: ReadonlySet<string>;
|
|
9
|
-
}
|
|
10
|
-
/** Immutable, exact-lookup registry pinned by a canonical digest. */
|
|
11
|
-
export declare class CrowdyAgentToolRegistry {
|
|
12
|
-
readonly contractVersion: "crowdy.agent-tools/1";
|
|
13
|
-
readonly registryDigest: `sha256:${string}`;
|
|
14
|
-
private readonly entries;
|
|
15
|
-
private readonly byLogical;
|
|
16
|
-
private readonly byWire;
|
|
17
|
-
constructor(descriptors: readonly CrowdyAgentToolDescriptorV1[]);
|
|
18
|
-
list(filter?: CrowdyAgentRegistryFilter): readonly CrowdyAgentRegisteredToolV1[];
|
|
19
|
-
get(name: string, version: string): CrowdyAgentRegisteredToolV1 | undefined;
|
|
20
|
-
require(name: string, version: string): CrowdyAgentRegisteredToolV1;
|
|
21
|
-
/** Exact, case-sensitive provider wire-name reverse lookup. */
|
|
22
|
-
fromWireName(wireName: string): CrowdyAgentRegisteredToolV1;
|
|
23
|
-
validateInput(name: string, version: string, value: unknown): void;
|
|
24
|
-
validateOutput(name: string, version: string, value: unknown): void;
|
|
25
|
-
/** Resolve conditional requirements from already validated arguments. */
|
|
26
|
-
requiredScopes(name: string, version: string, argumentsValue: unknown): readonly string[];
|
|
27
|
-
}
|
|
28
|
-
export declare function isDescriptorDigest(value: string): value is `sha256:${string}`;
|
|
29
|
-
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/crowdy-agent/registry.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EACV,eAAe,EACf,2BAA2B,EAC3B,2BAA2B,EAC3B,uBAAuB,EACxB,MAAM,YAAY,CAAC;AAUpB,wEAAwE;AACxE,eAAO,MAAM,6BAA6B,wOAsB/B,CAAC;AAEZ,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,IAAI,CAAC,EAAE,eAAe,CAAC;IAChC,QAAQ,CAAC,QAAQ,CAAC,EAAE,uBAAuB,CAAC;IAC5C,oEAAoE;IACpE,QAAQ,CAAC,eAAe,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;CAChD;AAED,qEAAqE;AACrE,qBAAa,uBAAuB;IAClC,QAAQ,CAAC,eAAe,EAAG,sBAAsB,CAAU;IAC3D,QAAQ,CAAC,cAAc,EAAE,UAAU,MAAM,EAAE,CAAC;IAC5C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAyC;IACjE,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAkD;IAC5E,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAkD;gBAE7D,WAAW,EAAE,SAAS,2BAA2B,EAAE;IA8B/D,IAAI,CAAC,MAAM,GAAE,yBAA8B,GAAG,SAAS,2BAA2B,EAAE;IAepF,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,2BAA2B,GAAG,SAAS;IAI3E,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,2BAA2B;IAcnE,+DAA+D;IAC/D,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,2BAA2B;IAW3D,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI;IAMlE,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI;IAMnE,yEAAyE;IACzE,cAAc,CACZ,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,cAAc,EAAE,OAAO,GACtB,SAAS,MAAM,EAAE;CAyBrB;AAoMD,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,UAAU,MAAM,EAAE,CAE7E"}
|
|
@@ -1,281 +0,0 @@
|
|
|
1
|
-
import { CrowdyAgentError } from './errors.js';
|
|
2
|
-
import { assertBoundedJsonSchema, canonicalJson, deepFreeze, digestCanonicalJson, validateJsonSchemaValue, } from './schema.js';
|
|
3
|
-
const WIRE_NAME = /^[A-Za-z0-9_-]{1,64}$/u;
|
|
4
|
-
const LOGICAL_NAME = /^(?:studio|project|workspace|library|template|diagnostics|runtime|game)\.[a-z0-9_]+(?:\.[a-z0-9_]+)*$/u;
|
|
5
|
-
const SEMVER = /^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$/u;
|
|
6
|
-
const DIGEST = /^sha256:[0-9a-f]{64}$/u;
|
|
7
|
-
const REDACTION_PATH = /^\$(?:\.[A-Za-z_][A-Za-z0-9_]*|\[\*\])*$/u;
|
|
8
|
-
/** Names whose presence would create ambient or arbitrary authority. */
|
|
9
|
-
export const FORBIDDEN_AGENT_TOOL_SURFACES = Object.freeze([
|
|
10
|
-
'graphql',
|
|
11
|
-
'fetch',
|
|
12
|
-
'http',
|
|
13
|
-
'url',
|
|
14
|
-
'socket',
|
|
15
|
-
'shell',
|
|
16
|
-
'process',
|
|
17
|
-
'filesystem',
|
|
18
|
-
'dom',
|
|
19
|
-
'keyboard',
|
|
20
|
-
'mouse',
|
|
21
|
-
'pointer',
|
|
22
|
-
'host_call',
|
|
23
|
-
'playercodebroker',
|
|
24
|
-
'udp',
|
|
25
|
-
'token',
|
|
26
|
-
'cookie',
|
|
27
|
-
'storage',
|
|
28
|
-
'devtools',
|
|
29
|
-
'database',
|
|
30
|
-
'buddy',
|
|
31
|
-
]);
|
|
32
|
-
/** Immutable, exact-lookup registry pinned by a canonical digest. */
|
|
33
|
-
export class CrowdyAgentToolRegistry {
|
|
34
|
-
constructor(descriptors) {
|
|
35
|
-
this.contractVersion = 'crowdy.agent-tools/1';
|
|
36
|
-
this.byLogical = new Map();
|
|
37
|
-
this.byWire = new Map();
|
|
38
|
-
if (descriptors.length === 0 || descriptors.length > 256) {
|
|
39
|
-
throw descriptorError('Registry must contain 1 to 256 tools');
|
|
40
|
-
}
|
|
41
|
-
const entries = descriptors
|
|
42
|
-
.map((descriptor) => registerDescriptor(descriptor))
|
|
43
|
-
.sort((left, right) => descriptorKey(left.descriptor).localeCompare(descriptorKey(right.descriptor)));
|
|
44
|
-
for (const entry of entries) {
|
|
45
|
-
const key = descriptorKey(entry.descriptor);
|
|
46
|
-
if (this.byLogical.has(key)) {
|
|
47
|
-
throw descriptorError(`Duplicate tool descriptor ${key}`);
|
|
48
|
-
}
|
|
49
|
-
if (this.byWire.has(entry.descriptor.wireName)) {
|
|
50
|
-
throw descriptorError(`Duplicate tool wire name ${entry.descriptor.wireName}`);
|
|
51
|
-
}
|
|
52
|
-
this.byLogical.set(key, entry);
|
|
53
|
-
this.byWire.set(entry.descriptor.wireName, entry);
|
|
54
|
-
}
|
|
55
|
-
this.entries = deepFreeze(entries);
|
|
56
|
-
this.registryDigest = digestCanonicalJson({
|
|
57
|
-
contract: this.contractVersion,
|
|
58
|
-
descriptors: entries.map(({ descriptor, descriptorDigest }) => ({
|
|
59
|
-
descriptor,
|
|
60
|
-
descriptorDigest,
|
|
61
|
-
})),
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
list(filter = {}) {
|
|
65
|
-
return this.entries.filter(({ descriptor }) => {
|
|
66
|
-
if (filter.mode && !descriptor.modes.includes(filter.mode))
|
|
67
|
-
return false;
|
|
68
|
-
if (filter.executor && descriptor.executor !== filter.executor)
|
|
69
|
-
return false;
|
|
70
|
-
if (filter.availableScopes) {
|
|
71
|
-
return descriptor.scopes
|
|
72
|
-
.filter((requirement) => !requirement.when)
|
|
73
|
-
.every((requirement) => filter.availableScopes?.has(requirement.scope));
|
|
74
|
-
}
|
|
75
|
-
return true;
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
get(name, version) {
|
|
79
|
-
return this.byLogical.get(`${name}@${version}`);
|
|
80
|
-
}
|
|
81
|
-
require(name, version) {
|
|
82
|
-
const entry = this.get(name, version);
|
|
83
|
-
if (!entry) {
|
|
84
|
-
const knownName = this.entries.some(({ descriptor }) => descriptor.name === name);
|
|
85
|
-
throw new CrowdyAgentError(knownName ? 'AGENT_TOOL_VERSION_UNSUPPORTED' : 'AGENT_TOOL_UNKNOWN', knownName
|
|
86
|
-
? `Unsupported ${name} tool version ${version}`
|
|
87
|
-
: `Unknown agent tool ${name}`);
|
|
88
|
-
}
|
|
89
|
-
return entry;
|
|
90
|
-
}
|
|
91
|
-
/** Exact, case-sensitive provider wire-name reverse lookup. */
|
|
92
|
-
fromWireName(wireName) {
|
|
93
|
-
const entry = this.byWire.get(wireName);
|
|
94
|
-
if (!entry) {
|
|
95
|
-
throw new CrowdyAgentError('AGENT_TOOL_UNKNOWN', `Unknown agent tool wire name ${wireName}`);
|
|
96
|
-
}
|
|
97
|
-
return entry;
|
|
98
|
-
}
|
|
99
|
-
validateInput(name, version, value) {
|
|
100
|
-
validateJsonSchemaValue(this.require(name, version).descriptor.inputSchema, value, {
|
|
101
|
-
direction: 'INPUT',
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
validateOutput(name, version, value) {
|
|
105
|
-
validateJsonSchemaValue(this.require(name, version).descriptor.outputSchema, value, {
|
|
106
|
-
direction: 'OUTPUT',
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
/** Resolve conditional requirements from already validated arguments. */
|
|
110
|
-
requiredScopes(name, version, argumentsValue) {
|
|
111
|
-
const entry = this.require(name, version);
|
|
112
|
-
this.validateInput(name, version, argumentsValue);
|
|
113
|
-
return entry.descriptor.scopes
|
|
114
|
-
.filter((requirement) => {
|
|
115
|
-
if (!requirement.when)
|
|
116
|
-
return true;
|
|
117
|
-
const values = resolveArgumentPath(argumentsValue, requirement.when.argumentPath);
|
|
118
|
-
return requirement.when.operator === 'EQUALS'
|
|
119
|
-
? values.some((value) => Object.is(value, requirement.when?.value))
|
|
120
|
-
: values.some((value) => Array.isArray(value) &&
|
|
121
|
-
value.some((entry) => Object.is(entry, requirement.when?.value))) ||
|
|
122
|
-
values.some((value) => Object.is(value, requirement.when?.value));
|
|
123
|
-
})
|
|
124
|
-
.map((requirement) => requirement.scope);
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
function registerDescriptor(source) {
|
|
128
|
-
validateDescriptor(source);
|
|
129
|
-
const descriptor = deepFreeze(JSON.parse(canonicalJson(source)));
|
|
130
|
-
const descriptorDigest = digestCanonicalJson(descriptor);
|
|
131
|
-
return deepFreeze({ descriptor, descriptorDigest });
|
|
132
|
-
}
|
|
133
|
-
function validateDescriptor(descriptor) {
|
|
134
|
-
if (descriptor.schemaVersion !== 'crowdy.agent-tool/1') {
|
|
135
|
-
throw descriptorError('Unsupported descriptor schemaVersion');
|
|
136
|
-
}
|
|
137
|
-
if (!LOGICAL_NAME.test(descriptor.name)) {
|
|
138
|
-
throw descriptorError(`Invalid logical tool name ${descriptor.name}`);
|
|
139
|
-
}
|
|
140
|
-
if (!WIRE_NAME.test(descriptor.wireName)) {
|
|
141
|
-
throw descriptorError(`Invalid tool wire name ${descriptor.wireName}`);
|
|
142
|
-
}
|
|
143
|
-
if (!SEMVER.test(descriptor.version)) {
|
|
144
|
-
throw descriptorError(`Invalid tool semantic version ${descriptor.version}`);
|
|
145
|
-
}
|
|
146
|
-
const major = descriptor.version.split('.')[0];
|
|
147
|
-
if (!descriptor.wireName.endsWith(`_v${major}`)) {
|
|
148
|
-
throw descriptorError(`Tool wire name ${descriptor.wireName} must include major suffix _v${major}`);
|
|
149
|
-
}
|
|
150
|
-
const authoritySurface = `${descriptor.name}.${descriptor.wireName}`.toLowerCase();
|
|
151
|
-
const forbidden = FORBIDDEN_AGENT_TOOL_SURFACES.find((part) => authoritySurface.includes(part));
|
|
152
|
-
if (forbidden) {
|
|
153
|
-
throw descriptorError(`Tool ${descriptor.name} exposes forbidden surface ${forbidden}`);
|
|
154
|
-
}
|
|
155
|
-
if (descriptor.summary.length < 8 || descriptor.summary.length > 240) {
|
|
156
|
-
throw descriptorError(`${descriptor.name} summary must be 8 to 240 characters`);
|
|
157
|
-
}
|
|
158
|
-
if (descriptor.modes.length === 0 ||
|
|
159
|
-
new Set(descriptor.modes).size !== descriptor.modes.length) {
|
|
160
|
-
throw descriptorError(`${descriptor.name} modes must be non-empty and unique`);
|
|
161
|
-
}
|
|
162
|
-
assertBoundedJsonSchema(descriptor.inputSchema, {
|
|
163
|
-
rejectAuthorityFields: true,
|
|
164
|
-
});
|
|
165
|
-
assertBoundedJsonSchema(descriptor.outputSchema, {
|
|
166
|
-
rejectAuthorityFields: false,
|
|
167
|
-
});
|
|
168
|
-
if (!Number.isSafeInteger(descriptor.timeoutMs) ||
|
|
169
|
-
descriptor.timeoutMs < 50 ||
|
|
170
|
-
descriptor.timeoutMs > 120000) {
|
|
171
|
-
throw descriptorError(`${descriptor.name} timeout must be 50..120000ms`);
|
|
172
|
-
}
|
|
173
|
-
if (!Number.isSafeInteger(descriptor.approval.maxTtlSeconds) ||
|
|
174
|
-
descriptor.approval.maxTtlSeconds < 0 ||
|
|
175
|
-
descriptor.approval.maxTtlSeconds > 300) {
|
|
176
|
-
throw descriptorError(`${descriptor.name} approval TTL must be 0..300 seconds`);
|
|
177
|
-
}
|
|
178
|
-
const approvalRequired = ['DESTRUCTIVE', 'TRUST_CONSENT', 'ECONOMIC', 'IRREVERSIBLE'].includes(descriptor.risk.class);
|
|
179
|
-
if (approvalRequired && descriptor.approval.policy !== 'REQUIRED') {
|
|
180
|
-
throw descriptorError(`${descriptor.name} risk requires exact human approval`);
|
|
181
|
-
}
|
|
182
|
-
if (descriptor.approval.policy === 'NONE' &&
|
|
183
|
-
(descriptor.approval.reasons.length !== 0 ||
|
|
184
|
-
descriptor.approval.maxTtlSeconds !== 0)) {
|
|
185
|
-
throw descriptorError(`${descriptor.name} no-approval metadata is inconsistent`);
|
|
186
|
-
}
|
|
187
|
-
if (descriptor.approval.policy !== 'NONE' &&
|
|
188
|
-
(descriptor.approval.reasons.length === 0 ||
|
|
189
|
-
descriptor.approval.maxTtlSeconds === 0)) {
|
|
190
|
-
throw descriptorError(`${descriptor.name} approval reasons and TTL are required`);
|
|
191
|
-
}
|
|
192
|
-
if (descriptor.executor === 'BROWSER' &&
|
|
193
|
-
!['PURE', 'TOOL_CALL_ONCE', 'NON_RETRYABLE'].includes(descriptor.idempotency.class)) {
|
|
194
|
-
throw descriptorError(`${descriptor.name} browser idempotency class is unsafe`);
|
|
195
|
-
}
|
|
196
|
-
validateKeyScope(descriptor);
|
|
197
|
-
validateRedaction(descriptor);
|
|
198
|
-
if (descriptor.scopes.length > 16) {
|
|
199
|
-
throw descriptorError(`${descriptor.name} has too many scope requirements`);
|
|
200
|
-
}
|
|
201
|
-
for (const requirement of descriptor.scopes) {
|
|
202
|
-
if (!/^[a-z][a-z0-9_.]{1,79}$/u.test(requirement.scope)) {
|
|
203
|
-
throw descriptorError(`${descriptor.name} has invalid scope ${requirement.scope}`);
|
|
204
|
-
}
|
|
205
|
-
if (requirement.when &&
|
|
206
|
-
(!REDACTION_PATH.test(requirement.when.argumentPath) ||
|
|
207
|
-
requirement.when.argumentPath.includes('[*]') === false &&
|
|
208
|
-
requirement.when.operator === 'CONTAINS')) {
|
|
209
|
-
throw descriptorError(`${descriptor.name} has invalid conditional scope`);
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
function validateKeyScope(descriptor) {
|
|
214
|
-
const expected = descriptor.idempotency.class === 'PURE'
|
|
215
|
-
? 'NONE'
|
|
216
|
-
: descriptor.idempotency.class === 'KEYED'
|
|
217
|
-
? 'USER_TOOL_ARGUMENTS'
|
|
218
|
-
: 'TOOL_CALL';
|
|
219
|
-
if (descriptor.idempotency.keyScope !== expected) {
|
|
220
|
-
throw descriptorError(`${descriptor.name} idempotency key scope must be ${expected}`);
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
function validateRedaction(descriptor) {
|
|
224
|
-
if (!Number.isSafeInteger(descriptor.redaction.maxPersistedBytes) ||
|
|
225
|
-
descriptor.redaction.maxPersistedBytes < 0 ||
|
|
226
|
-
descriptor.redaction.maxPersistedBytes > 65536) {
|
|
227
|
-
throw descriptorError(`${descriptor.name} persisted byte bound is invalid`);
|
|
228
|
-
}
|
|
229
|
-
for (const rule of [
|
|
230
|
-
...descriptor.redaction.input,
|
|
231
|
-
...descriptor.redaction.output,
|
|
232
|
-
]) {
|
|
233
|
-
if (!REDACTION_PATH.test(rule.path)) {
|
|
234
|
-
throw descriptorError(`${descriptor.name} has invalid redaction path ${rule.path}`);
|
|
235
|
-
}
|
|
236
|
-
if (rule.action === 'TRUNCATE' &&
|
|
237
|
-
(!Number.isSafeInteger(rule.maxBytes) ||
|
|
238
|
-
(rule.maxBytes ?? 0) < 1 ||
|
|
239
|
-
(rule.maxBytes ?? 0) > descriptor.redaction.maxPersistedBytes)) {
|
|
240
|
-
throw descriptorError(`${descriptor.name} truncate rule needs bounded maxBytes`);
|
|
241
|
-
}
|
|
242
|
-
if (rule.action !== 'TRUNCATE' && rule.maxBytes !== undefined) {
|
|
243
|
-
throw descriptorError(`${descriptor.name} maxBytes is only valid for TRUNCATE`);
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
function descriptorKey(descriptor) {
|
|
248
|
-
return `${descriptor.name}@${descriptor.version}`;
|
|
249
|
-
}
|
|
250
|
-
function descriptorError(message) {
|
|
251
|
-
return new CrowdyAgentError('AGENT_TOOL_DESCRIPTOR_INVALID', message);
|
|
252
|
-
}
|
|
253
|
-
function resolveArgumentPath(value, path) {
|
|
254
|
-
const segments = path
|
|
255
|
-
.slice(2)
|
|
256
|
-
.split('.')
|
|
257
|
-
.filter(Boolean);
|
|
258
|
-
let values = [value];
|
|
259
|
-
for (const segment of segments) {
|
|
260
|
-
const wildcard = segment.endsWith('[*]');
|
|
261
|
-
const key = wildcard ? segment.slice(0, -3) : segment;
|
|
262
|
-
const next = [];
|
|
263
|
-
for (const candidate of values) {
|
|
264
|
-
if (candidate === null ||
|
|
265
|
-
typeof candidate !== 'object' ||
|
|
266
|
-
Array.isArray(candidate)) {
|
|
267
|
-
continue;
|
|
268
|
-
}
|
|
269
|
-
const child = candidate[key];
|
|
270
|
-
if (wildcard && Array.isArray(child))
|
|
271
|
-
next.push(...child);
|
|
272
|
-
else if (!wildcard)
|
|
273
|
-
next.push(child);
|
|
274
|
-
}
|
|
275
|
-
values = next;
|
|
276
|
-
}
|
|
277
|
-
return values;
|
|
278
|
-
}
|
|
279
|
-
export function isDescriptorDigest(value) {
|
|
280
|
-
return DIGEST.test(value);
|
|
281
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/crowdy-agent/schema.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC;AAE7D,UAAU,cAAc;IACtB,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,aAAa,EAAE,CAAC;IACzC,QAAQ,CAAC,KAAK,CAAC,EAAE,aAAa,CAAC;CAChC;AAED,MAAM,WAAW,gBAAiB,SAAQ,cAAc;IACtD,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;I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EAAE,MAAM,GAAG,OAAO,CAEtD"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type { CrowdyAgentSessionV1 } from './types.js';
|
|
2
|
-
/**
|
|
3
|
-
* Fresh create+attach usually writes SESSION_CREATED, CLIENT_ATTACHED, and
|
|
4
|
-
* maybe MODE_SELECTED. Anything above this has a real turn.
|
|
5
|
-
*/
|
|
6
|
-
export declare const AGENT_SESSION_EMPTYISH_LAST_SEQ = 3n;
|
|
7
|
-
export interface StudioSessionMemory {
|
|
8
|
-
get(key: string): string | null;
|
|
9
|
-
set(key: string, value: string): void;
|
|
10
|
-
}
|
|
11
|
-
export interface AgentSessionResumeBinding {
|
|
12
|
-
readonly projectId?: string;
|
|
13
|
-
readonly gridId?: string;
|
|
14
|
-
readonly preferredSessionId?: string | null;
|
|
15
|
-
}
|
|
16
|
-
export declare function agentSessionMemoryKey(appId: string, projectId?: string): string;
|
|
17
|
-
export declare function browserSessionMemory(): StudioSessionMemory | null;
|
|
18
|
-
/**
|
|
19
|
-
* Choose the session Studio should reopen instead of creating another empty
|
|
20
|
-
* one. Preferred id wins; otherwise a session that already has turns beats a
|
|
21
|
-
* pile of unused create-on-open leftovers; then latest `updatedAt`.
|
|
22
|
-
*/
|
|
23
|
-
export declare function pickResumableAgentSession(sessions: readonly CrowdyAgentSessionV1[], binding: AgentSessionResumeBinding): CrowdyAgentSessionV1 | null;
|
|
24
|
-
//# sourceMappingURL=session-resume.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"session-resume.d.ts","sourceRoot":"","sources":["../../src/crowdy-agent/session-resume.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAKvD;;;GAGG;AACH,eAAO,MAAM,+BAA+B,KAAK,CAAC;AAElD,MAAM,WAAW,mBAAmB;IAClC,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IAChC,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACvC;AAED,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,kBAAkB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7C;AAED,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,MAAM,EACb,SAAS,CAAC,EAAE,MAAM,GACjB,MAAM,CAER;AAED,wBAAgB,oBAAoB,IAAI,mBAAmB,GAAG,IAAI,CAajE;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,SAAS,oBAAoB,EAAE,EACzC,OAAO,EAAE,yBAAyB,GACjC,oBAAoB,GAAG,IAAI,CA0B7B"}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
/** Statuses that can be reattached after Studio closes. */
|
|
2
|
-
const REOPENABLE = new Set(['ACTIVE', 'PAUSED']);
|
|
3
|
-
/**
|
|
4
|
-
* Fresh create+attach usually writes SESSION_CREATED, CLIENT_ATTACHED, and
|
|
5
|
-
* maybe MODE_SELECTED. Anything above this has a real turn.
|
|
6
|
-
*/
|
|
7
|
-
export const AGENT_SESSION_EMPTYISH_LAST_SEQ = 3n;
|
|
8
|
-
export function agentSessionMemoryKey(appId, projectId) {
|
|
9
|
-
return `ck-crowdy-studio-agent-session:${appId}:${projectId ?? '_'}`;
|
|
10
|
-
}
|
|
11
|
-
export function browserSessionMemory() {
|
|
12
|
-
try {
|
|
13
|
-
if (typeof window === 'undefined')
|
|
14
|
-
return null;
|
|
15
|
-
const storage = window.localStorage;
|
|
16
|
-
return {
|
|
17
|
-
get: (key) => storage.getItem(key),
|
|
18
|
-
set: (key, value) => {
|
|
19
|
-
storage.setItem(key, value);
|
|
20
|
-
},
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
catch {
|
|
24
|
-
return null;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Choose the session Studio should reopen instead of creating another empty
|
|
29
|
-
* one. Preferred id wins; otherwise a session that already has turns beats a
|
|
30
|
-
* pile of unused create-on-open leftovers; then latest `updatedAt`.
|
|
31
|
-
*/
|
|
32
|
-
export function pickResumableAgentSession(sessions, binding) {
|
|
33
|
-
const candidates = sessions.filter((session) => sessionMatchesBinding(session, binding));
|
|
34
|
-
if (candidates.length === 0)
|
|
35
|
-
return null;
|
|
36
|
-
const preferredId = binding.preferredSessionId;
|
|
37
|
-
if (preferredId) {
|
|
38
|
-
const preferred = candidates.find((session) => session.sessionId === preferredId);
|
|
39
|
-
if (preferred)
|
|
40
|
-
return preferred;
|
|
41
|
-
}
|
|
42
|
-
const withTurns = candidates.filter((session) => eventSeq(session.lastEventSeq) > AGENT_SESSION_EMPTYISH_LAST_SEQ);
|
|
43
|
-
const pool = withTurns.length > 0 ? withTurns : candidates;
|
|
44
|
-
return ([...pool].sort((left, right) => {
|
|
45
|
-
const updated = right.updatedAt.localeCompare(left.updatedAt);
|
|
46
|
-
if (updated !== 0)
|
|
47
|
-
return updated;
|
|
48
|
-
const seq = eventSeq(right.lastEventSeq) - eventSeq(left.lastEventSeq);
|
|
49
|
-
return seq > 0n ? 1 : seq < 0n ? -1 : 0;
|
|
50
|
-
})[0] ?? null);
|
|
51
|
-
}
|
|
52
|
-
function sessionMatchesBinding(session, binding) {
|
|
53
|
-
if (!REOPENABLE.has(session.status))
|
|
54
|
-
return false;
|
|
55
|
-
if (binding.projectId) {
|
|
56
|
-
if (session.projectId !== binding.projectId)
|
|
57
|
-
return false;
|
|
58
|
-
}
|
|
59
|
-
else if (session.projectId) {
|
|
60
|
-
return false;
|
|
61
|
-
}
|
|
62
|
-
if (binding.gridId &&
|
|
63
|
-
session.gridId &&
|
|
64
|
-
session.gridId !== binding.gridId) {
|
|
65
|
-
return false;
|
|
66
|
-
}
|
|
67
|
-
return true;
|
|
68
|
-
}
|
|
69
|
-
function eventSeq(value) {
|
|
70
|
-
try {
|
|
71
|
-
return BigInt(value);
|
|
72
|
-
}
|
|
73
|
-
catch {
|
|
74
|
-
return 0n;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { CrowdyStudioController } from '../crowdy-studio/controller.js';
|
|
2
|
-
import { projectTargets } from '../crowdy-studio/models.js';
|
|
3
|
-
import type { CrowdyAgentBrowserToolHandlersV1 } from './browser-dispatcher.js';
|
|
4
|
-
export interface CrowdyStudioAgentToolsOptionsV1 {
|
|
5
|
-
readonly getClientEpoch?: () => string | null;
|
|
6
|
-
readonly getContextVersion?: () => string | undefined;
|
|
7
|
-
readonly getLeaseKinds?: () => readonly ('WORKSPACE' | 'PLAY')[];
|
|
8
|
-
readonly getHostCapabilityRevision?: () => string | undefined;
|
|
9
|
-
readonly isLeaseActive?: (leaseId: string, kind: 'WORKSPACE' | 'PLAY') => boolean;
|
|
10
|
-
}
|
|
11
|
-
/** Exact browser tools backed by the same headless kernel as the human UI. */
|
|
12
|
-
export declare function createCrowdyStudioAgentTools(controller: CrowdyStudioController, options?: CrowdyStudioAgentToolsOptionsV1): CrowdyAgentBrowserToolHandlersV1;
|
|
13
|
-
/** Keep the canonical target helper reachable for BWF host integrations. */
|
|
14
|
-
export declare const crowdyStudioAgentProjectTargets: typeof projectTargets;
|
|
15
|
-
//# sourceMappingURL=studio-tools.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"studio-tools.d.ts","sourceRoot":"","sources":["../../src/crowdy-agent/studio-tools.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAC7E,OAAO,EACL,cAAc,EAGf,MAAM,4BAA4B,CAAC;AAEpC,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,yBAAyB,CAAC;AAGhF,MAAM,WAAW,+BAA+B;IAC9C,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,MAAM,GAAG,IAAI,CAAC;IAC9C,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,MAAM,GAAG,SAAS,CAAC;IACtD,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,SAAS,CAAC,WAAW,GAAG,MAAM,CAAC,EAAE,CAAC;IACjE,QAAQ,CAAC,yBAAyB,CAAC,EAAE,MAAM,MAAM,GAAG,SAAS,CAAC;IAC9D,QAAQ,CAAC,aAAa,CAAC,EAAE,CACvB,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,WAAW,GAAG,MAAM,KACvB,OAAO,CAAC;CACd;AAED,8EAA8E;AAC9E,wBAAgB,4BAA4B,CAC1C,UAAU,EAAE,sBAAsB,EAClC,OAAO,GAAE,+BAAoC,GAC5C,gCAAgC,CAgNlC;AAsND,4EAA4E;AAC5E,eAAO,MAAM,+BAA+B,uBAAiB,CAAC"}
|