@granular-software/sdk 0.4.31 → 0.4.32

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.
@@ -9,7 +9,7 @@ import { Doc } from '@automerge/automerge/slim';
9
9
  * Configuration for the Granular client
10
10
  */
11
11
  type AccessTokenProvider = () => Promise<string | null | undefined> | string | null | undefined;
12
- type EndpointMode = "auto" | "local" | "production";
12
+ type EndpointMode = 'auto' | 'local' | 'production';
13
13
  interface GranularOptions {
14
14
  /** Your Granular API key (for service/CLI auth; use with GRANULAR_API_KEY) */
15
15
  apiKey?: string;
@@ -86,15 +86,16 @@ interface Subject {
86
86
  updatedAt: number;
87
87
  }
88
88
  /**
89
- * Options for opening or resolving an ontology environment for one user.
89
+ * Options for opening an ontology environment for one delegated subject.
90
90
  *
91
- * This does **not** open a session. Use `environment.sessions.create()` after
92
- * opening the environment when you need a live runtime connection.
91
+ * This does not open a live runtime session. Use
92
+ * `environment.sessions.create()` or `granular.createSession({ environmentId })`
93
+ * when you need a conversation/session with jobs, prompts, heap, and effects.
93
94
  */
94
95
  interface OpenEnvironmentOptions {
95
- /** The ontology name or ID to open */
96
+ /** The ontology name or ID to open. */
96
97
  ontology: string;
97
- /** Version channel to follow, typically `dev` or `prod` */
98
+ /** Version channel to follow, typically `dev` or `prod`. */
98
99
  tag?: string;
99
100
  /**
100
101
  * External user identifier from your app.
@@ -108,9 +109,9 @@ interface OpenEnvironmentOptions {
108
109
  * Exactly one of `userId`, `granularId`, or `user` should be provided.
109
110
  */
110
111
  granularId?: string;
111
- /** Optional display name used when upserting the user */
112
+ /** Optional display name used when upserting the user. */
112
113
  name?: string;
113
- /** Optional email used when upserting the user */
114
+ /** Optional email used when upserting the user. */
114
115
  email?: string;
115
116
  /**
116
117
  * Permission profile names or IDs to ensure before opening the environment.
@@ -124,14 +125,14 @@ interface OpenEnvironmentOptions {
124
125
  * the newest tag target instead of reusing the outdated one.
125
126
  */
126
127
  createFreshIfOutdated?: boolean;
127
- /** Backwards-compatible user object returned from recordUser() */
128
+ /** Backwards-compatible user object returned from `recordUser()`. */
128
129
  user?: User;
129
130
  }
130
131
  /**
131
132
  * Deprecated compatibility alias for the legacy `connect()` entry point.
132
133
  *
133
- * `connect()` now resolves an environment handle and no longer opens a
134
- * runtime session automatically. Prefer `openEnvironment()` for new code.
134
+ * `connect()` now resolves an environment handle and no longer opens a runtime
135
+ * session automatically. Prefer `openEnvironment()` for new code.
135
136
  */
136
137
  interface ConnectOptions extends OpenEnvironmentOptions {
137
138
  /** @deprecated Legacy explicit environment slot name. Prefer `tag`. */
@@ -167,7 +168,7 @@ interface ConversationSessionInfo {
167
168
  environmentId: string;
168
169
  versionId?: string | null;
169
170
  docId: string;
170
- status: "active" | "closed" | "expired";
171
+ status: 'active' | 'closed' | 'expired';
171
172
  createdAt: string;
172
173
  lastSeenAt: string;
173
174
  summary?: string | null;
@@ -275,7 +276,7 @@ interface AssignmentListResponse {
275
276
  * pin themselves to one immutable ontology version.
276
277
  */
277
278
  interface BuildPolicy {
278
- mode: "tag" | "current" | "pinned";
279
+ mode: 'tag' | 'current' | 'pinned';
279
280
  buildId?: string;
280
281
  versionId?: string;
281
282
  tagId?: string;
@@ -286,7 +287,7 @@ interface VersionTag {
286
287
  tagId: string;
287
288
  sandboxId: string;
288
289
  name: string;
289
- kind: "channel" | "release" | "system";
290
+ kind: 'channel' | 'release' | 'system';
290
291
  targetBuildId?: string | null;
291
292
  targetVersionId?: string | null;
292
293
  description?: string | null;
@@ -311,7 +312,7 @@ interface EnvironmentData {
311
312
  tag?: VersionTag | null;
312
313
  tracking?: BuildPolicy;
313
314
  buildPolicy: BuildPolicy;
314
- updateState?: "up_to_date" | "update_available" | "upgrading" | "failed";
315
+ updateState?: 'up_to_date' | 'update_available' | 'upgrading' | 'failed';
315
316
  createdAt: number;
316
317
  updatedAt: number;
317
318
  }
@@ -360,7 +361,7 @@ interface Manifest {
360
361
  interface ManifestListResponse {
361
362
  items: Manifest[];
362
363
  }
363
- type BuildStatus = "queued" | "building" | "completed" | "failed" | "canceled";
364
+ type BuildStatus = 'queued' | 'building' | 'completed' | 'failed' | 'canceled';
364
365
  /**
365
366
  * An immutable ontology version derived from a specific manifest revision.
366
367
  *
@@ -395,8 +396,8 @@ interface BuildListResponse {
395
396
  }
396
397
  interface SemanticVersionDiffEntry {
397
398
  operationId: string;
398
- kind: "create" | "update" | "relationship" | "effect" | "eventStream" | "unknown";
399
- changeType: "added" | "removed" | "changed";
399
+ kind: 'create' | 'update' | 'relationship' | 'effect' | 'eventStream' | 'unknown';
400
+ changeType: 'added' | 'removed' | 'changed';
400
401
  label: string;
401
402
  additive: boolean;
402
403
  breaking: boolean;
@@ -458,7 +459,7 @@ interface ResolvedEffectBehaviors {
458
459
  reverse?: ResolvedEffectReverse;
459
460
  approvalRequired?: ResolvedEffectApprovalRequired;
460
461
  }
461
- type EffectInvocationMode = "execute" | "dryRun" | "reverse";
462
+ type EffectInvocationMode = 'execute' | 'dryRun' | 'reverse';
462
463
  interface EffectInvocationMetadata {
463
464
  mode?: EffectInvocationMode;
464
465
  reverseHandler?: string;
@@ -515,9 +516,9 @@ interface ToolSchema {
515
516
  * ```
516
517
  */
517
518
  outputSchema?: Record<string, unknown>;
518
- stability?: "stable" | "experimental" | "deprecated";
519
+ stability?: 'stable' | 'experimental' | 'deprecated';
519
520
  provenance?: {
520
- source: "mcp" | "custom";
521
+ source: 'mcp' | 'custom';
521
522
  };
522
523
  tags?: string[];
523
524
  /**
@@ -624,8 +625,8 @@ interface EffectsChangedEvent extends ToolsChangedEvent {
624
625
  }
625
626
  type EffectHandler = ToolHandler;
626
627
  type InstanceEffectHandler = InstanceToolHandler;
627
- type JobStatus = "queued" | "running" | "awaitingTool" | "awaitingHuman" | "succeeded" | "failed" | "timeout" | "canceled";
628
- type JobFeedbackSentiment = "good" | "bad";
628
+ type JobStatus = 'queued' | 'running' | 'awaitingTool' | 'awaitingHuman' | 'succeeded' | 'failed' | 'timeout' | 'canceled';
629
+ type JobFeedbackSentiment = 'good' | 'bad';
629
630
  interface JobFeedbackToolCall {
630
631
  callId?: string;
631
632
  toolName?: string;
@@ -637,7 +638,7 @@ interface JobFeedbackToolCall {
637
638
  durationMs?: number | null;
638
639
  }
639
640
  interface JobFeedbackMetadata {
640
- source: "sdk";
641
+ source: 'sdk';
641
642
  status: JobStatus;
642
643
  code: string;
643
644
  domainRevision?: string;
@@ -671,7 +672,7 @@ interface JobFeedbackRecord {
671
672
  updatedAt: number;
672
673
  }
673
674
  /**
674
- * Persisted feedback rows listed at the environment level.
675
+ * Persisted feedback row listed at the environment level.
675
676
  */
676
677
  interface EnvironmentFeedbackRecord {
677
678
  feedbackId: string;
@@ -701,11 +702,11 @@ interface Job {
701
702
  /** Attach user feedback to this job and persist it with job/session metadata */
702
703
  leaveFeedback(input: JobFeedbackInput): Promise<JobFeedbackRecord>;
703
704
  /** Subscribe to job events */
704
- on(event: string, handler: (data: unknown) => void): void;
705
+ on(event: string, handler: (data: unknown) => void): () => void;
705
706
  }
706
707
  interface Prompt {
707
708
  id: string;
708
- type: "confirm" | "choice" | "input";
709
+ type: 'confirm' | 'choice' | 'input';
709
710
  title: string;
710
711
  message: string;
711
712
  options?: Array<string | {
@@ -724,7 +725,7 @@ interface ConversationMessageShowRefs {
724
725
  variableNames?: string[];
725
726
  }
726
727
  interface ConversationMessageInput {
727
- role: "user" | "assistant";
728
+ role: 'user' | 'assistant';
728
729
  content?: string;
729
730
  show?: ConversationMessageShowRefs;
730
731
  jobId?: string;
@@ -740,7 +741,7 @@ interface ConversationAppendResult {
740
741
  }
741
742
  interface SessionTranscriptEntry {
742
743
  id: string;
743
- role: "user" | "assistant";
744
+ role: 'user' | 'assistant';
744
745
  content: string;
745
746
  timestamp: number;
746
747
  jobId?: string;
@@ -751,9 +752,9 @@ interface SessionTranscriptEntry {
751
752
  error?: string;
752
753
  show?: ConversationMessageShowRefs;
753
754
  historyContent?: string;
754
- source: "conversation" | "job_code" | "job_result" | "job_prompt" | "job_agent_message";
755
+ source: 'conversation' | 'job_code' | 'job_result' | 'job_prompt' | 'job_agent_message';
755
756
  }
756
- type SessionHeapFieldType = "string" | "number" | "boolean" | "null" | "unknown";
757
+ type SessionHeapFieldType = 'string' | 'number' | 'boolean' | 'null' | 'unknown';
757
758
  interface SessionHeapFieldValue {
758
759
  name: string;
759
760
  type: SessionHeapFieldType;
@@ -781,7 +782,7 @@ interface SessionHeapList {
781
782
  }
782
783
  interface SessionHeapVariable {
783
784
  name: string;
784
- kind: "entry" | "list" | "scalar";
785
+ kind: 'entry' | 'list' | 'scalar';
785
786
  entryPath?: string;
786
787
  listName?: string;
787
788
  value?: string | number | boolean | null;
@@ -818,13 +819,13 @@ interface WSClientOptions {
818
819
  onReconnectError?: (info: WSReconnectErrorInfo) => void;
819
820
  }
820
821
  interface RPCRequest {
821
- type: "rpc";
822
+ type: 'rpc';
822
823
  method: string;
823
824
  params: unknown;
824
825
  id: string;
825
826
  }
826
827
  interface RPCResponse {
827
- type: "rpc_result" | "rpc_error";
828
+ type: 'rpc_result' | 'rpc_error';
828
829
  id: string;
829
830
  result?: unknown;
830
831
  error?: {
@@ -834,12 +835,12 @@ interface RPCResponse {
834
835
  };
835
836
  }
836
837
  interface SyncMessage {
837
- type: "sync";
838
+ type: 'sync';
838
839
  message?: string | number[] | Uint8Array;
839
840
  data?: number[];
840
841
  }
841
842
  interface RPCRequestFromServer {
842
- type: "rpc";
843
+ type: 'rpc';
843
844
  method: string;
844
845
  params: unknown;
845
846
  id: string;
@@ -883,7 +884,7 @@ interface RelationshipInfo {
883
884
  /** The foreign model type */
884
885
  foreign_model: ModelRef;
885
886
  /** Computed relationship kind: "one_to_one" | "one_to_many" | "many_to_one" | "many_to_many" */
886
- relationship_kind: "one_to_one" | "one_to_many" | "many_to_one" | "many_to_many";
887
+ relationship_kind: 'one_to_one' | 'one_to_many' | 'many_to_one' | 'many_to_many';
887
888
  }
888
889
  /**
889
890
  * Options for defining a relationship between two model types
@@ -982,8 +983,8 @@ interface RecordObjectsOptions {
982
983
  */
983
984
  onChunkComplete?: (info: RecordObjectsChunkInfo) => void | Promise<void>;
984
985
  }
985
- type RecordImportStatus = "queued" | "processing" | "completed" | "failed" | "canceled";
986
- type RecordImportItemStatus = "queued" | "processing" | "completed" | "failed" | "canceled";
986
+ type RecordImportStatus = 'queued' | 'processing' | 'completed' | 'failed' | 'canceled';
987
+ type RecordImportItemStatus = 'queued' | 'processing' | 'completed' | 'failed' | 'canceled';
987
988
  interface RecordImportStats {
988
989
  totalRecords: number;
989
990
  queuedRecords: number;
@@ -1048,14 +1049,10 @@ interface ManifestPropertySpec {
1048
1049
  required?: boolean;
1049
1050
  note?: string | string[];
1050
1051
  enum?: string[] | ManifestEnumRuleSpec;
1051
- searchable?: boolean | {
1052
- enabled?: boolean;
1053
- phonetic?: boolean;
1054
- };
1055
1052
  filterBy?: boolean | string[] | ManifestFilterBySpec;
1056
1053
  validate?: ManifestValidationRuleSpec[];
1057
1054
  }
1058
- type ManifestValidationOperator = "eq" | "neq" | "gt" | "gte" | "lt" | "lte" | "true" | "false" | "regex" | "contains" | "not_contains" | "starts_with" | "ends_with";
1055
+ type ManifestValidationOperator = 'eq' | 'neq' | 'gt' | 'gte' | 'lt' | 'lte' | 'true' | 'false' | 'regex' | 'contains' | 'not_contains' | 'starts_with' | 'ends_with';
1059
1056
  interface ManifestEnumRuleSpec {
1060
1057
  values: string[];
1061
1058
  message?: string;
@@ -1144,7 +1141,7 @@ interface ManifestEffectDeclaration {
1144
1141
  isStatic?: boolean;
1145
1142
  inputSchema: ManifestEffectSchema;
1146
1143
  outputSchema?: ManifestEffectSchema;
1147
- stability?: "stable" | "experimental" | "deprecated";
1144
+ stability?: 'stable' | 'experimental' | 'deprecated';
1148
1145
  tags?: string[];
1149
1146
  metamodels?: ManifestEffectMetamodelSpec;
1150
1147
  }
@@ -1205,7 +1202,7 @@ interface ManifestImport {
1205
1202
  }
1206
1203
  interface ManifestVolume {
1207
1204
  name: string;
1208
- scope: "sandbox" | "build" | "user";
1205
+ scope: 'sandbox' | 'build' | 'user';
1209
1206
  imports?: ManifestImport[];
1210
1207
  operations: ManifestOperation[];
1211
1208
  }
@@ -1248,7 +1245,7 @@ interface StreamEvent {
1248
1245
  environmentId: string;
1249
1246
  sessionId?: string;
1250
1247
  subjectId?: string;
1251
- source: "sandbox" | "api";
1248
+ source: 'sandbox' | 'api';
1252
1249
  isAcked: boolean;
1253
1250
  createdAt: number;
1254
1251
  }
@@ -1480,7 +1477,7 @@ declare class Session {
1480
1477
  /**
1481
1478
  * Subscribe to session events
1482
1479
  */
1483
- on(event: string, handler: (data: unknown) => void): void;
1480
+ on(event: string, handler: (data: unknown) => void): () => void;
1484
1481
  /**
1485
1482
  * Unsubscribe from session events
1486
1483
  */
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { E as EndpointMode, T as ToolWithHandler, a as EffectHandlerContext, M as ManifestEffectMetamodelSpec, R as ResolvedEffectBehaviors, S as SessionHeapEntry, b as SessionHeapList, c as SessionHeapSnapshot, P as Prompt, d as SessionTranscriptEntry } from './client-CTH1hfwe.mjs';
2
- export { ba as APIError, A as AccessTokenProvider, y as Assignment, z as AssignmentListResponse, X as Build, Z as BuildListResponse, B as BuildPolicy, Q as BuildStatus, C as ConnectOptions, aq as ConversationAppendResult, ap as ConversationMessageInput, ao as ConversationMessageShowRefs, q as ConversationSessionInfo, J as CreateEnvironmentData, w as CreatePermissionProfileData, s as CreateSandboxData, p as CreateSessionOptions, aF as DefineRelationshipOptions, bb as DeleteResponse, D as DomainState, ad as EffectHandler, aa as EffectInfo, a5 as EffectInvocationMetadata, a4 as EffectInvocationMode, a6 as EffectSchema, a7 as EffectWithHandler, ac as EffectsChangedEvent, e as Environment, H as EnvironmentData, al as EnvironmentFeedbackRecord, K as EnvironmentListResponse, aP as EnvironmentRecordImportSummary, f as EnvironmentSession, G as Granular, l as GranularAuth, k as GranularOptions, b9 as GraphQLResult, ae as InstanceEffectHandler, I as InstanceToolHandler, an as Job, aj as JobFeedbackInput, ai as JobFeedbackMetadata, ak as JobFeedbackRecord, ag as JobFeedbackSentiment, ah as JobFeedbackToolCall, af as JobStatus, am as JobSubmitResult, L as Manifest, a$ as ManifestApprovalRequiredSpec, b8 as ManifestContent, aZ as ManifestDryRunSpec, b2 as ManifestEffectDeclaration, b1 as ManifestEffectSchema, aS as ManifestEnumRuleSpec, b4 as ManifestEventStreamDef, b3 as ManifestEventTypeDef, aT as ManifestFilterBySpec, b6 as ManifestImport, N as ManifestListResponse, b5 as ManifestOperation, aY as ManifestPostConditionSpec, aQ as ManifestPropertySpec, b0 as ManifestRelationshipDef, a_ as ManifestReverseSpec, aX as ManifestStateMachineSpec, aV as ManifestStateMachineStateSpec, aW as ManifestStateMachineTransitionSpec, aR as ManifestValidationOperator, aU as ManifestValidationRuleSpec, b7 as ManifestVolume, aD as ModelRef, O as OntologyHandle, o as OpenEnvironmentOptions, v as PermissionProfile, x as PermissionProfileListResponse, u as PermissionRules, a8 as PublishEffectsResult, i as PublishToolsResult, ax as RPCRequest, aA as RPCRequestFromServer, ay as RPCResponse, aO as RecordImport, aN as RecordImportItem, aL as RecordImportItemStatus, aM as RecordImportStats, aK as RecordImportStatus, aG as RecordObjectOptions, aH as RecordObjectResult, aI as RecordObjectsChunkInfo, aJ as RecordObjectsOptions, m as RecordUserOptions, aE as RelationshipInfo, a3 as ResolvedEffectApprovalRequired, a1 as ResolvedEffectDryRun, a0 as ResolvedEffectPostCondition, a2 as ResolvedEffectReverse, r as Sandbox, t as SandboxListResponse, $ as SemanticVersionDiff, _ as SemanticVersionDiffEntry, g as Session, ar as SessionHeapFieldType, as as SessionHeapFieldValue, at as SessionHeapVariable, bc as StreamEvent, be as StreamStats, bd as StreamSubscription, n as Subject, az as SyncMessage, j as ToolHandler, a9 as ToolInfo, aB as ToolInvokeParams, aC as ToolResultParams, h as ToolSchema, ab as ToolsChangedEvent, U as User, Y as Version, F as VersionTag, V as VersionTracking, W as WSClient, aw as WSClientOptions, au as WSDisconnectInfo, av as WSReconnectErrorInfo } from './client-CTH1hfwe.mjs';
1
+ import { E as EndpointMode, T as ToolWithHandler, a as EffectHandlerContext, M as ManifestEffectMetamodelSpec, R as ResolvedEffectBehaviors, S as SessionHeapEntry, b as SessionHeapList, c as SessionHeapSnapshot, P as Prompt, d as SessionTranscriptEntry } from './client-C2Gk641P.mjs';
2
+ export { ba as APIError, A as AccessTokenProvider, y as Assignment, z as AssignmentListResponse, X as Build, Z as BuildListResponse, B as BuildPolicy, Q as BuildStatus, C as ConnectOptions, aq as ConversationAppendResult, ap as ConversationMessageInput, ao as ConversationMessageShowRefs, q as ConversationSessionInfo, J as CreateEnvironmentData, w as CreatePermissionProfileData, s as CreateSandboxData, p as CreateSessionOptions, aF as DefineRelationshipOptions, bb as DeleteResponse, D as DomainState, ad as EffectHandler, aa as EffectInfo, a5 as EffectInvocationMetadata, a4 as EffectInvocationMode, a6 as EffectSchema, a7 as EffectWithHandler, ac as EffectsChangedEvent, e as Environment, H as EnvironmentData, al as EnvironmentFeedbackRecord, K as EnvironmentListResponse, aP as EnvironmentRecordImportSummary, f as EnvironmentSession, G as Granular, l as GranularAuth, k as GranularOptions, b9 as GraphQLResult, ae as InstanceEffectHandler, I as InstanceToolHandler, an as Job, aj as JobFeedbackInput, ai as JobFeedbackMetadata, ak as JobFeedbackRecord, ag as JobFeedbackSentiment, ah as JobFeedbackToolCall, af as JobStatus, am as JobSubmitResult, L as Manifest, a$ as ManifestApprovalRequiredSpec, b8 as ManifestContent, aZ as ManifestDryRunSpec, b2 as ManifestEffectDeclaration, b1 as ManifestEffectSchema, aS as ManifestEnumRuleSpec, b4 as ManifestEventStreamDef, b3 as ManifestEventTypeDef, aT as ManifestFilterBySpec, b6 as ManifestImport, N as ManifestListResponse, b5 as ManifestOperation, aY as ManifestPostConditionSpec, aQ as ManifestPropertySpec, b0 as ManifestRelationshipDef, a_ as ManifestReverseSpec, aX as ManifestStateMachineSpec, aV as ManifestStateMachineStateSpec, aW as ManifestStateMachineTransitionSpec, aR as ManifestValidationOperator, aU as ManifestValidationRuleSpec, b7 as ManifestVolume, aD as ModelRef, O as OntologyHandle, o as OpenEnvironmentOptions, v as PermissionProfile, x as PermissionProfileListResponse, u as PermissionRules, a8 as PublishEffectsResult, i as PublishToolsResult, ax as RPCRequest, aA as RPCRequestFromServer, ay as RPCResponse, aO as RecordImport, aN as RecordImportItem, aL as RecordImportItemStatus, aM as RecordImportStats, aK as RecordImportStatus, aG as RecordObjectOptions, aH as RecordObjectResult, aI as RecordObjectsChunkInfo, aJ as RecordObjectsOptions, m as RecordUserOptions, aE as RelationshipInfo, a3 as ResolvedEffectApprovalRequired, a1 as ResolvedEffectDryRun, a0 as ResolvedEffectPostCondition, a2 as ResolvedEffectReverse, r as Sandbox, t as SandboxListResponse, $ as SemanticVersionDiff, _ as SemanticVersionDiffEntry, g as Session, ar as SessionHeapFieldType, as as SessionHeapFieldValue, at as SessionHeapVariable, bc as StreamEvent, be as StreamStats, bd as StreamSubscription, n as Subject, az as SyncMessage, j as ToolHandler, a9 as ToolInfo, aB as ToolInvokeParams, aC as ToolResultParams, h as ToolSchema, ab as ToolsChangedEvent, U as User, Y as Version, F as VersionTag, V as VersionTracking, W as WSClient, aw as WSClientOptions, au as WSDisconnectInfo, av as WSReconnectErrorInfo } from './client-C2Gk641P.mjs';
3
3
  export { BuildGranularAgentSystemPromptInput, GeneratedJobCodeIssue, GranularAgentExecutionCheckpoint, GranularAgentHeapSummaryOptions, GranularAgentReferentFocus, GranularAgentSessionContext, GranularAgentToolInfo, GranularAgentWorkflowFocus, HarnessContinuationDecision, HarnessControllerBudgets, HarnessProjectionOptions, HarnessPromptLike, HarnessVerifierSnapshot, HarnessVerifierSnapshotInput, buildContinuationInstruction, buildGranularAgentCheckpointBlock, buildGranularAgentDomainBlock, buildGranularAgentHeapBlock, buildGranularAgentLoopBlock, buildGranularAgentReferentBlock, buildGranularAgentSessionBlock, buildGranularAgentSystemPrompt, buildGranularAgentToolBlock, buildGranularAgentWorkflowBlock, createHarnessVerifierSnapshot, evaluateContinuation, getCurrentClosureId, getExclusivePromptTarget, hasOpenPrompt, projectConversationReferentFocus, projectConversationReferentSummary, projectHeapSummary, projectLoopSummary, projectWorkflowFocus, projectWorkflowSummary, reviewGeneratedJobCode } from './agent-harness.mjs';
4
4
  import '@automerge/automerge';
5
5
  import '@automerge/automerge/slim';
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { E as EndpointMode, T as ToolWithHandler, a as EffectHandlerContext, M as ManifestEffectMetamodelSpec, R as ResolvedEffectBehaviors, S as SessionHeapEntry, b as SessionHeapList, c as SessionHeapSnapshot, P as Prompt, d as SessionTranscriptEntry } from './client-CTH1hfwe.js';
2
- export { ba as APIError, A as AccessTokenProvider, y as Assignment, z as AssignmentListResponse, X as Build, Z as BuildListResponse, B as BuildPolicy, Q as BuildStatus, C as ConnectOptions, aq as ConversationAppendResult, ap as ConversationMessageInput, ao as ConversationMessageShowRefs, q as ConversationSessionInfo, J as CreateEnvironmentData, w as CreatePermissionProfileData, s as CreateSandboxData, p as CreateSessionOptions, aF as DefineRelationshipOptions, bb as DeleteResponse, D as DomainState, ad as EffectHandler, aa as EffectInfo, a5 as EffectInvocationMetadata, a4 as EffectInvocationMode, a6 as EffectSchema, a7 as EffectWithHandler, ac as EffectsChangedEvent, e as Environment, H as EnvironmentData, al as EnvironmentFeedbackRecord, K as EnvironmentListResponse, aP as EnvironmentRecordImportSummary, f as EnvironmentSession, G as Granular, l as GranularAuth, k as GranularOptions, b9 as GraphQLResult, ae as InstanceEffectHandler, I as InstanceToolHandler, an as Job, aj as JobFeedbackInput, ai as JobFeedbackMetadata, ak as JobFeedbackRecord, ag as JobFeedbackSentiment, ah as JobFeedbackToolCall, af as JobStatus, am as JobSubmitResult, L as Manifest, a$ as ManifestApprovalRequiredSpec, b8 as ManifestContent, aZ as ManifestDryRunSpec, b2 as ManifestEffectDeclaration, b1 as ManifestEffectSchema, aS as ManifestEnumRuleSpec, b4 as ManifestEventStreamDef, b3 as ManifestEventTypeDef, aT as ManifestFilterBySpec, b6 as ManifestImport, N as ManifestListResponse, b5 as ManifestOperation, aY as ManifestPostConditionSpec, aQ as ManifestPropertySpec, b0 as ManifestRelationshipDef, a_ as ManifestReverseSpec, aX as ManifestStateMachineSpec, aV as ManifestStateMachineStateSpec, aW as ManifestStateMachineTransitionSpec, aR as ManifestValidationOperator, aU as ManifestValidationRuleSpec, b7 as ManifestVolume, aD as ModelRef, O as OntologyHandle, o as OpenEnvironmentOptions, v as PermissionProfile, x as PermissionProfileListResponse, u as PermissionRules, a8 as PublishEffectsResult, i as PublishToolsResult, ax as RPCRequest, aA as RPCRequestFromServer, ay as RPCResponse, aO as RecordImport, aN as RecordImportItem, aL as RecordImportItemStatus, aM as RecordImportStats, aK as RecordImportStatus, aG as RecordObjectOptions, aH as RecordObjectResult, aI as RecordObjectsChunkInfo, aJ as RecordObjectsOptions, m as RecordUserOptions, aE as RelationshipInfo, a3 as ResolvedEffectApprovalRequired, a1 as ResolvedEffectDryRun, a0 as ResolvedEffectPostCondition, a2 as ResolvedEffectReverse, r as Sandbox, t as SandboxListResponse, $ as SemanticVersionDiff, _ as SemanticVersionDiffEntry, g as Session, ar as SessionHeapFieldType, as as SessionHeapFieldValue, at as SessionHeapVariable, bc as StreamEvent, be as StreamStats, bd as StreamSubscription, n as Subject, az as SyncMessage, j as ToolHandler, a9 as ToolInfo, aB as ToolInvokeParams, aC as ToolResultParams, h as ToolSchema, ab as ToolsChangedEvent, U as User, Y as Version, F as VersionTag, V as VersionTracking, W as WSClient, aw as WSClientOptions, au as WSDisconnectInfo, av as WSReconnectErrorInfo } from './client-CTH1hfwe.js';
1
+ import { E as EndpointMode, T as ToolWithHandler, a as EffectHandlerContext, M as ManifestEffectMetamodelSpec, R as ResolvedEffectBehaviors, S as SessionHeapEntry, b as SessionHeapList, c as SessionHeapSnapshot, P as Prompt, d as SessionTranscriptEntry } from './client-C2Gk641P.js';
2
+ export { ba as APIError, A as AccessTokenProvider, y as Assignment, z as AssignmentListResponse, X as Build, Z as BuildListResponse, B as BuildPolicy, Q as BuildStatus, C as ConnectOptions, aq as ConversationAppendResult, ap as ConversationMessageInput, ao as ConversationMessageShowRefs, q as ConversationSessionInfo, J as CreateEnvironmentData, w as CreatePermissionProfileData, s as CreateSandboxData, p as CreateSessionOptions, aF as DefineRelationshipOptions, bb as DeleteResponse, D as DomainState, ad as EffectHandler, aa as EffectInfo, a5 as EffectInvocationMetadata, a4 as EffectInvocationMode, a6 as EffectSchema, a7 as EffectWithHandler, ac as EffectsChangedEvent, e as Environment, H as EnvironmentData, al as EnvironmentFeedbackRecord, K as EnvironmentListResponse, aP as EnvironmentRecordImportSummary, f as EnvironmentSession, G as Granular, l as GranularAuth, k as GranularOptions, b9 as GraphQLResult, ae as InstanceEffectHandler, I as InstanceToolHandler, an as Job, aj as JobFeedbackInput, ai as JobFeedbackMetadata, ak as JobFeedbackRecord, ag as JobFeedbackSentiment, ah as JobFeedbackToolCall, af as JobStatus, am as JobSubmitResult, L as Manifest, a$ as ManifestApprovalRequiredSpec, b8 as ManifestContent, aZ as ManifestDryRunSpec, b2 as ManifestEffectDeclaration, b1 as ManifestEffectSchema, aS as ManifestEnumRuleSpec, b4 as ManifestEventStreamDef, b3 as ManifestEventTypeDef, aT as ManifestFilterBySpec, b6 as ManifestImport, N as ManifestListResponse, b5 as ManifestOperation, aY as ManifestPostConditionSpec, aQ as ManifestPropertySpec, b0 as ManifestRelationshipDef, a_ as ManifestReverseSpec, aX as ManifestStateMachineSpec, aV as ManifestStateMachineStateSpec, aW as ManifestStateMachineTransitionSpec, aR as ManifestValidationOperator, aU as ManifestValidationRuleSpec, b7 as ManifestVolume, aD as ModelRef, O as OntologyHandle, o as OpenEnvironmentOptions, v as PermissionProfile, x as PermissionProfileListResponse, u as PermissionRules, a8 as PublishEffectsResult, i as PublishToolsResult, ax as RPCRequest, aA as RPCRequestFromServer, ay as RPCResponse, aO as RecordImport, aN as RecordImportItem, aL as RecordImportItemStatus, aM as RecordImportStats, aK as RecordImportStatus, aG as RecordObjectOptions, aH as RecordObjectResult, aI as RecordObjectsChunkInfo, aJ as RecordObjectsOptions, m as RecordUserOptions, aE as RelationshipInfo, a3 as ResolvedEffectApprovalRequired, a1 as ResolvedEffectDryRun, a0 as ResolvedEffectPostCondition, a2 as ResolvedEffectReverse, r as Sandbox, t as SandboxListResponse, $ as SemanticVersionDiff, _ as SemanticVersionDiffEntry, g as Session, ar as SessionHeapFieldType, as as SessionHeapFieldValue, at as SessionHeapVariable, bc as StreamEvent, be as StreamStats, bd as StreamSubscription, n as Subject, az as SyncMessage, j as ToolHandler, a9 as ToolInfo, aB as ToolInvokeParams, aC as ToolResultParams, h as ToolSchema, ab as ToolsChangedEvent, U as User, Y as Version, F as VersionTag, V as VersionTracking, W as WSClient, aw as WSClientOptions, au as WSDisconnectInfo, av as WSReconnectErrorInfo } from './client-C2Gk641P.js';
3
3
  export { BuildGranularAgentSystemPromptInput, GeneratedJobCodeIssue, GranularAgentExecutionCheckpoint, GranularAgentHeapSummaryOptions, GranularAgentReferentFocus, GranularAgentSessionContext, GranularAgentToolInfo, GranularAgentWorkflowFocus, HarnessContinuationDecision, HarnessControllerBudgets, HarnessProjectionOptions, HarnessPromptLike, HarnessVerifierSnapshot, HarnessVerifierSnapshotInput, buildContinuationInstruction, buildGranularAgentCheckpointBlock, buildGranularAgentDomainBlock, buildGranularAgentHeapBlock, buildGranularAgentLoopBlock, buildGranularAgentReferentBlock, buildGranularAgentSessionBlock, buildGranularAgentSystemPrompt, buildGranularAgentToolBlock, buildGranularAgentWorkflowBlock, createHarnessVerifierSnapshot, evaluateContinuation, getCurrentClosureId, getExclusivePromptTarget, hasOpenPrompt, projectConversationReferentFocus, projectConversationReferentSummary, projectHeapSummary, projectLoopSummary, projectWorkflowFocus, projectWorkflowSummary, reviewGeneratedJobCode } from './agent-harness.js';
4
4
  import '@automerge/automerge';
5
5
  import '@automerge/automerge/slim';
package/dist/index.js CHANGED
@@ -4005,7 +4005,11 @@ var WSClient = class {
4005
4005
  return null;
4006
4006
  }
4007
4007
  try {
4008
- const payloadRaw = this.decodeBase64Url(parts[1]);
4008
+ const payloadSegment = parts[1];
4009
+ if (!payloadSegment) {
4010
+ return null;
4011
+ }
4012
+ const payloadRaw = this.decodeBase64Url(payloadSegment);
4009
4013
  const payload = JSON.parse(payloadRaw);
4010
4014
  if (typeof payload.exp !== "number" || !Number.isFinite(payload.exp)) {
4011
4015
  return null;
@@ -5082,6 +5086,7 @@ import { ${allImports} } from "./sandbox-tools";
5082
5086
  this.eventListeners.set(event, []);
5083
5087
  }
5084
5088
  this.eventListeners.get(event).push(handler);
5089
+ return () => this.off(event, handler);
5085
5090
  }
5086
5091
  /**
5087
5092
  * Unsubscribe from session events
@@ -5538,6 +5543,16 @@ var JobImplementation = class {
5538
5543
  handler(message);
5539
5544
  }
5540
5545
  }
5546
+ return () => {
5547
+ const handlers = this.eventListeners.get(event);
5548
+ if (!handlers) {
5549
+ return;
5550
+ }
5551
+ this.eventListeners.set(
5552
+ event,
5553
+ handlers.filter((current) => current !== handler)
5554
+ );
5555
+ };
5541
5556
  }
5542
5557
  replayAgentMessage(message) {
5543
5558
  this.captureAgentMessage(message);
@@ -12084,7 +12099,9 @@ var Environment = class {
12084
12099
  }
12085
12100
  );
12086
12101
  if (result.errors?.length) {
12087
- throw new Error(`defineRelationship failed: ${result.errors[0].message}`);
12102
+ throw new Error(
12103
+ `defineRelationship failed: ${result.errors[0]?.message ?? "Unknown GraphQL error"}`
12104
+ );
12088
12105
  }
12089
12106
  return result.data.at.define_relationship;
12090
12107
  }
@@ -12120,7 +12137,9 @@ var Environment = class {
12120
12137
  { path: modelPath }
12121
12138
  );
12122
12139
  if (result.errors?.length) {
12123
- throw new Error(`getRelationships failed: ${result.errors[0].message}`);
12140
+ throw new Error(
12141
+ `getRelationships failed: ${result.errors[0]?.message ?? "Unknown GraphQL error"}`
12142
+ );
12124
12143
  }
12125
12144
  return result.data?.model?.relationships || [];
12126
12145
  }
@@ -12159,7 +12178,7 @@ var Environment = class {
12159
12178
  { target: targetPath }
12160
12179
  );
12161
12180
  if (result.errors?.length) {
12162
- throw new Error(`attach failed: ${result.errors[0].message}`);
12181
+ throw new Error(`attach failed: ${result.errors[0]?.message ?? "Unknown GraphQL error"}`);
12163
12182
  }
12164
12183
  }
12165
12184
  /**
@@ -12194,7 +12213,7 @@ var Environment = class {
12194
12213
  }`
12195
12214
  );
12196
12215
  if (result.errors?.length) {
12197
- throw new Error(`detach failed: ${result.errors[0].message}`);
12216
+ throw new Error(`detach failed: ${result.errors[0]?.message ?? "Unknown GraphQL error"}`);
12198
12217
  }
12199
12218
  }
12200
12219
  /**
@@ -12221,7 +12240,9 @@ var Environment = class {
12221
12240
  }`
12222
12241
  );
12223
12242
  if (result.errors?.length) {
12224
- throw new Error(`listRelated failed: ${result.errors[0].message}`);
12243
+ throw new Error(
12244
+ `listRelated failed: ${result.errors[0]?.message ?? "Unknown GraphQL error"}`
12245
+ );
12225
12246
  }
12226
12247
  return result.data?.at?.at?.list_related || [];
12227
12248
  }
@@ -12314,7 +12335,7 @@ var Environment = class {
12314
12335
  async _runGraphql(query, label) {
12315
12336
  const result = await this.graphql(query);
12316
12337
  if (result.errors?.length) {
12317
- throw new Error(`${label}: ${result.errors[0].message}`);
12338
+ throw new Error(`${label}: ${result.errors[0]?.message ?? "Unknown GraphQL error"}`);
12318
12339
  }
12319
12340
  return result.data;
12320
12341
  }
@@ -12659,7 +12680,11 @@ var Environment = class {
12659
12680
  */
12660
12681
  async recordObject(options) {
12661
12682
  const results = await this.recordObjects([options]);
12662
- return results[0];
12683
+ const result = results[0];
12684
+ if (!result) {
12685
+ throw new Error("recordObject: no result returned for record");
12686
+ }
12687
+ return result;
12663
12688
  }
12664
12689
  /**
12665
12690
  * Batch version of `recordObject()`.
@@ -12711,7 +12736,13 @@ var Environment = class {
12711
12736
  );
12712
12737
  }
12713
12738
  for (let index = 0; index < items.length; index += 1) {
12714
- results[plan.offset + index] = items[index];
12739
+ const item = items[index];
12740
+ if (!item) {
12741
+ throw new Error(
12742
+ `recordObjects: chunk ${plan.chunkIndex + 1} returned an empty result at index ${index}`
12743
+ );
12744
+ }
12745
+ results[plan.offset + index] = item;
12715
12746
  }
12716
12747
  if (onChunk) {
12717
12748
  const info = {