@opengeni/contracts 2.6.0-canary.0 → 2.7.0

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/src/index.ts CHANGED
@@ -13,6 +13,12 @@ import { ClientResumableVoiceInputConfig } from "./transcription-recordings";
13
13
  import { MediaGenerationResult } from "./video-generation";
14
14
  import { KnowledgeProviderCitation } from "./knowledge";
15
15
  import { XaiProviderAccountAuthoritySnapshotV1 } from "./xai-provider-account-authority";
16
+ import {
17
+ MAX_NESTED_AGENT_DEPTH,
18
+ NestedAgentDepthValue,
19
+ SessionGoalStatus,
20
+ SessionStatus,
21
+ } from "./session-topology-primitives";
16
22
 
17
23
  export * from "./slack-bot-scopes";
18
24
  export * from "./slack-task-policy";
@@ -31,6 +37,9 @@ export * from "./interaction";
31
37
  export * from "./sandbox-file-artifacts";
32
38
  export * from "./permissions";
33
39
  export * from "./session-titles";
40
+ export * from "./session-topology-primitives";
41
+ export * from "./agent-topology";
42
+ export * from "./work-claims";
34
43
 
35
44
  export {
36
45
  CreateWorkspaceArtifactRequest,
@@ -149,18 +158,6 @@ export {
149
158
  type ModalCheckpointProviderBinding,
150
159
  } from "./checkpoint-provider-bindings";
151
160
 
152
- export const SessionStatus = z.enum([
153
- "queued",
154
- "running",
155
- "idle",
156
- "requires_action",
157
- "recovering",
158
- "waiting_capacity",
159
- "failed",
160
- "cancelled",
161
- ]);
162
- export type SessionStatus = z.infer<typeof SessionStatus>;
163
-
164
161
  // 12 backends; 3-way enum parity (contracts / sdk / deployment) is pinned by
165
162
  // `packages/sdk/test/contract-parity.test.ts`. Every member is ADDITIVE AT THE
166
163
  // END (the parity test pins positions): the original four, then the six cloud
@@ -680,10 +677,6 @@ export const ErrorEnvelope = z.object({
680
677
  });
681
678
  export type ErrorEnvelope = z.infer<typeof ErrorEnvelope>;
682
679
 
683
- /** Physical ceiling of the PostgreSQL integer columns that persist depth policy. */
684
- export const MAX_NESTED_AGENT_DEPTH = 2_147_483_647;
685
- export const NestedAgentDepthValue = z.number().int().nonnegative().max(MAX_NESTED_AGENT_DEPTH);
686
- export type NestedAgentDepthValue = z.infer<typeof NestedAgentDepthValue>;
687
680
  /** A denied child can be one greater than the persisted PostgreSQL int ceiling. */
688
681
  export const NestedAgentDepthAttemptValue = z
689
682
  .number()
@@ -779,6 +772,8 @@ export const FIRST_PARTY_MCP_TOOL_NAMES = [
779
772
  "task_note_save",
780
773
  "task_note_archive",
781
774
  "task_note_replace",
775
+ "work_claim_upsert",
776
+ "work_claim_release",
782
777
  "knowledge_propose",
783
778
  "knowledge_correct",
784
779
  "task_note_promote_knowledge",
@@ -5563,9 +5558,6 @@ export type SessionControlState = z.infer<typeof SessionControlState>;
5563
5558
  export const WorkspaceInferenceState = z.enum(["active", "paused"]);
5564
5559
  export type WorkspaceInferenceState = z.infer<typeof WorkspaceInferenceState>;
5565
5560
 
5566
- export const SessionGoalStatus = z.enum(["active", "paused", "completed"]);
5567
- export type SessionGoalStatus = z.infer<typeof SessionGoalStatus>;
5568
-
5569
5561
  export const SessionGoalCreatedBy = z.enum(["api", "agent", "scheduled_task"]);
5570
5562
  export type SessionGoalCreatedBy = z.infer<typeof SessionGoalCreatedBy>;
5571
5563
 
@@ -11725,57 +11717,6 @@ export const SessionListResponse = z.object({
11725
11717
  });
11726
11718
  export type SessionListResponse = z.infer<typeof SessionListResponse>;
11727
11719
 
11728
- /** Compact, bounded session projection for workspace agent-topology browsers. */
11729
- export const AgentTopologySession = z.object({
11730
- id: z.string().uuid(),
11731
- title: z.string().nullable(),
11732
- titleTruncated: z.boolean(),
11733
- parentSessionId: z.string().uuid().nullable(),
11734
- rootSessionId: z.string().uuid(),
11735
- nestedAgentDepth: NestedAgentDepthValue,
11736
- ancestorPath: z.array(
11737
- z.object({
11738
- id: z.string().uuid(),
11739
- title: z.string().nullable(),
11740
- titleTruncated: z.boolean(),
11741
- }),
11742
- ),
11743
- status: SessionStatus,
11744
- pause: z.object({
11745
- state: z.enum(["active", "paused"]),
11746
- additionalBlockerCount: z.number().int().nonnegative(),
11747
- source: z
11748
- .object({
11749
- kind: z.enum(["session", "workspace"]),
11750
- sessionId: z.string().uuid().optional(),
11751
- displayName: z.string(),
11752
- displayNameTruncated: z.boolean(),
11753
- })
11754
- .nullable(),
11755
- }),
11756
- children: z.object({
11757
- directChildren: z.number().int().nonnegative(),
11758
- totalDescendants: z.number().int().nonnegative(),
11759
- runningDescendants: z.number().int().nonnegative(),
11760
- queuedDescendants: z.number().int().nonnegative(),
11761
- attentionDescendants: z.number().int().nonnegative(),
11762
- pausedDescendants: z.number().int().nonnegative(),
11763
- failedDescendants: z.number().int().nonnegative(),
11764
- truncated: z.boolean(),
11765
- }),
11766
- createdAt: z.string(),
11767
- updatedAt: z.string(),
11768
- });
11769
- export type AgentTopologySession = z.infer<typeof AgentTopologySession>;
11770
-
11771
- export const AgentTopologyPageResponse = z.object({
11772
- sessions: z.array(AgentTopologySession),
11773
- total: z.number().int().nonnegative(),
11774
- hasMore: z.boolean(),
11775
- nextCursor: z.string().nullable(),
11776
- });
11777
- export type AgentTopologyPageResponse = z.infer<typeof AgentTopologyPageResponse>;
11778
-
11779
11720
  // Recursive: the TS type is declared first so the schema annotation can carry
11780
11721
  // the FULL recursive shape (a shallow annotation loses type information for
11781
11722
  // contracts consumers after one level of nesting).
@@ -0,0 +1,21 @@
1
+ import { z } from "zod";
2
+
3
+ export const SessionStatus = z.enum([
4
+ "queued",
5
+ "running",
6
+ "idle",
7
+ "requires_action",
8
+ "recovering",
9
+ "waiting_capacity",
10
+ "failed",
11
+ "cancelled",
12
+ ]);
13
+ export type SessionStatus = z.infer<typeof SessionStatus>;
14
+
15
+ export const SessionGoalStatus = z.enum(["active", "paused", "completed"]);
16
+ export type SessionGoalStatus = z.infer<typeof SessionGoalStatus>;
17
+
18
+ /** Physical ceiling of the PostgreSQL integer columns that persist depth policy. */
19
+ export const MAX_NESTED_AGENT_DEPTH = 2_147_483_647;
20
+ export const NestedAgentDepthValue = z.number().int().nonnegative().max(MAX_NESTED_AGENT_DEPTH);
21
+ export type NestedAgentDepthValue = z.infer<typeof NestedAgentDepthValue>;
@@ -0,0 +1,266 @@
1
+ import { z } from "zod";
2
+ import { normalizeAutomaticSessionTitle } from "./session-titles";
3
+
4
+ export const WORK_CLAIM_NAMESPACE_MAX_BYTES = 64;
5
+ export const WORK_CLAIM_CANONICAL_KEY_MAX_BYTES = 512;
6
+ export const WORK_CLAIM_DISPLAY_LABEL_MAX_BYTES = 256;
7
+ export const WORK_CLAIM_VERSION_VALUE_MAX_BYTES = 256;
8
+ export const WORK_CLAIM_ACTIVE_SESSION_CAP = 64;
9
+ export const WORK_CLAIM_DISCOVERY_LIMIT = 8;
10
+ export const WORK_CLAIM_DISCOVERY_DEFAULT_LIMIT = 4;
11
+ export const WORK_DISCOVERY_QUERY_MAX_CHARS = 200;
12
+ export const WORK_DISCOVERY_RECENT_HOURS_MAX = 24 * 365;
13
+
14
+ const utf8Bytes = (value: string): number => new TextEncoder().encode(value).byteLength;
15
+ const CONTROL_CHARACTERS = /[\u0000-\u001f\u007f-\u009f]/u;
16
+ const NAMESPACE_PATTERN = /^[a-z0-9](?:[a-z0-9._:-]{0,62}[a-z0-9])?$/u;
17
+
18
+ function boundedCanonicalText(maxBytes: number, label: string) {
19
+ return z
20
+ .string()
21
+ .min(1)
22
+ .superRefine((value, context) => {
23
+ if (value !== value.trim()) {
24
+ context.addIssue({
25
+ code: z.ZodIssueCode.custom,
26
+ message: `${label} must not have leading or trailing whitespace`,
27
+ });
28
+ }
29
+ if (value !== value.normalize("NFKC")) {
30
+ context.addIssue({
31
+ code: z.ZodIssueCode.custom,
32
+ message: `${label} must use canonical Unicode normalization`,
33
+ });
34
+ }
35
+ if (CONTROL_CHARACTERS.test(value)) {
36
+ context.addIssue({
37
+ code: z.ZodIssueCode.custom,
38
+ message: `${label} must not contain control characters`,
39
+ });
40
+ }
41
+ if (utf8Bytes(value) > maxBytes) {
42
+ context.addIssue({
43
+ code: z.ZodIssueCode.custom,
44
+ message: `${label} must be at most ${maxBytes} UTF-8 bytes`,
45
+ });
46
+ }
47
+ });
48
+ }
49
+
50
+ export function normalizeWorkClaimNamespace(value: string): string {
51
+ return value.normalize("NFKC").trim().toLowerCase();
52
+ }
53
+
54
+ export function normalizeWorkClaimCanonicalKey(value: string): string {
55
+ return value.normalize("NFKC").trim();
56
+ }
57
+
58
+ export function normalizeWorkClaimDisplayLabel(value: string): string | null {
59
+ const normalized = normalizeAutomaticSessionTitle(value);
60
+ if (!normalized || utf8Bytes(normalized) > WORK_CLAIM_DISPLAY_LABEL_MAX_BYTES) return null;
61
+ return normalized;
62
+ }
63
+
64
+ export const WorkClaimNamespace = z
65
+ .string()
66
+ .min(1)
67
+ .max(WORK_CLAIM_NAMESPACE_MAX_BYTES)
68
+ .regex(NAMESPACE_PATTERN)
69
+ .refine((value) => value === normalizeWorkClaimNamespace(value), {
70
+ message: "work claim namespace must already be canonical lowercase text",
71
+ });
72
+ export type WorkClaimNamespace = z.infer<typeof WorkClaimNamespace>;
73
+
74
+ export const WorkClaimCanonicalKey = boundedCanonicalText(
75
+ WORK_CLAIM_CANONICAL_KEY_MAX_BYTES,
76
+ "work claim canonical key",
77
+ );
78
+ export type WorkClaimCanonicalKey = z.infer<typeof WorkClaimCanonicalKey>;
79
+
80
+ export const WorkClaimDisplayLabel = z
81
+ .string()
82
+ .min(1)
83
+ .superRefine((value, context) => {
84
+ if (utf8Bytes(value) > WORK_CLAIM_DISPLAY_LABEL_MAX_BYTES) {
85
+ context.addIssue({
86
+ code: z.ZodIssueCode.custom,
87
+ message: `work claim display label must be at most ${WORK_CLAIM_DISPLAY_LABEL_MAX_BYTES} UTF-8 bytes`,
88
+ });
89
+ }
90
+ if (normalizeWorkClaimDisplayLabel(value) !== value) {
91
+ context.addIssue({
92
+ code: z.ZodIssueCode.custom,
93
+ message: "work claim display label must be a safe concise semantic label",
94
+ });
95
+ }
96
+ });
97
+ export type WorkClaimDisplayLabel = z.infer<typeof WorkClaimDisplayLabel>;
98
+
99
+ export const WorkClaimSubjectType = z.enum([
100
+ "repository",
101
+ "branch",
102
+ "pull_request",
103
+ "issue",
104
+ "artifact",
105
+ "release",
106
+ "ci_run",
107
+ "other",
108
+ ]);
109
+ export type WorkClaimSubjectType = z.infer<typeof WorkClaimSubjectType>;
110
+
111
+ export const WorkClaimRole = z.enum(["working", "reviewing", "monitoring", "delivering"]);
112
+ export type WorkClaimRole = z.infer<typeof WorkClaimRole>;
113
+
114
+ export const WorkClaimState = z.enum(["active", "released", "superseded", "stale"]);
115
+ export type WorkClaimState = z.infer<typeof WorkClaimState>;
116
+
117
+ export const WorkClaimProvenance = z.enum([
118
+ "explicit_agent",
119
+ "user_api",
120
+ "trusted_integration",
121
+ "session_resource",
122
+ "system_lifecycle",
123
+ ]);
124
+ export type WorkClaimProvenance = z.infer<typeof WorkClaimProvenance>;
125
+
126
+ export const WorkClaimVersionKind = z.enum([
127
+ "git_commit",
128
+ "branch_head",
129
+ "pull_request_head",
130
+ "artifact_version",
131
+ "release_version",
132
+ "ci_run",
133
+ "other",
134
+ ]);
135
+ export type WorkClaimVersionKind = z.infer<typeof WorkClaimVersionKind>;
136
+
137
+ export const WorkClaimVersionValue = boundedCanonicalText(
138
+ WORK_CLAIM_VERSION_VALUE_MAX_BYTES,
139
+ "work claim version value",
140
+ );
141
+ export type WorkClaimVersionValue = z.infer<typeof WorkClaimVersionValue>;
142
+
143
+ export const WorkClaimReleaseReason = z.enum([
144
+ "completed",
145
+ "cancelled",
146
+ "failed",
147
+ "superseded",
148
+ "no_longer_active",
149
+ "corrected",
150
+ "external_state_changed",
151
+ "other",
152
+ ]);
153
+ export type WorkClaimReleaseReason = z.infer<typeof WorkClaimReleaseReason>;
154
+
155
+ export const WorkClaimMutationKind = z.enum([
156
+ "created",
157
+ "updated",
158
+ "released",
159
+ "superseded",
160
+ "stale",
161
+ ]);
162
+ export type WorkClaimMutationKind = z.infer<typeof WorkClaimMutationKind>;
163
+
164
+ export const WorkClaim = z.object({
165
+ id: z.string().uuid(),
166
+ sessionId: z.string().uuid(),
167
+ rootSessionId: z.string().uuid(),
168
+ subject: z.object({
169
+ namespace: WorkClaimNamespace,
170
+ type: WorkClaimSubjectType,
171
+ canonicalKey: WorkClaimCanonicalKey,
172
+ displayLabel: WorkClaimDisplayLabel.nullable(),
173
+ }),
174
+ role: WorkClaimRole,
175
+ state: WorkClaimState,
176
+ revision: z.number().int().positive(),
177
+ provenance: WorkClaimProvenance,
178
+ version: z
179
+ .object({
180
+ kind: WorkClaimVersionKind,
181
+ value: WorkClaimVersionValue,
182
+ })
183
+ .nullable(),
184
+ observedAt: z.string().datetime({ offset: true }),
185
+ createdAt: z.string().datetime({ offset: true }),
186
+ updatedAt: z.string().datetime({ offset: true }),
187
+ settledAt: z.string().datetime({ offset: true }).nullable(),
188
+ });
189
+ export type WorkClaim = z.infer<typeof WorkClaim>;
190
+
191
+ export const WorkClaimMutationResult = z.object({
192
+ claim: WorkClaim,
193
+ mutation: WorkClaimMutationKind,
194
+ replayed: z.boolean(),
195
+ });
196
+ export type WorkClaimMutationResult = z.infer<typeof WorkClaimMutationResult>;
197
+
198
+ export const WorkClaimDiscoverySummary = WorkClaim.pick({
199
+ id: true,
200
+ sessionId: true,
201
+ subject: true,
202
+ role: true,
203
+ state: true,
204
+ revision: true,
205
+ provenance: true,
206
+ version: true,
207
+ observedAt: true,
208
+ updatedAt: true,
209
+ settledAt: true,
210
+ });
211
+ export type WorkClaimDiscoverySummary = z.infer<typeof WorkClaimDiscoverySummary>;
212
+
213
+ export const WorkClaimSubjectFilter = z
214
+ .object({
215
+ namespace: WorkClaimNamespace,
216
+ type: WorkClaimSubjectType,
217
+ canonicalKey: WorkClaimCanonicalKey,
218
+ })
219
+ .strict();
220
+ export type WorkClaimSubjectFilter = z.infer<typeof WorkClaimSubjectFilter>;
221
+
222
+ export const WorkDiscoveryMatchClass = z.enum(["exact_subject", "title", "goal", "fuzzy"]);
223
+ export type WorkDiscoveryMatchClass = z.infer<typeof WorkDiscoveryMatchClass>;
224
+
225
+ export const WorkDiscoveryMatchedField = z.enum([
226
+ "subject",
227
+ "title",
228
+ "goal",
229
+ "claim_key",
230
+ "claim_label",
231
+ ]);
232
+ export type WorkDiscoveryMatchedField = z.infer<typeof WorkDiscoveryMatchedField>;
233
+
234
+ /**
235
+ * Deliberately stable bands rather than a raw ranking score. Raw full-text or
236
+ * trigram values are query-relative and become a misleading cross-query API.
237
+ */
238
+ export const WorkDiscoveryScoreBand = z.enum(["exact", "strong", "related"]);
239
+ export type WorkDiscoveryScoreBand = z.infer<typeof WorkDiscoveryScoreBand>;
240
+
241
+ export const WorkDiscoveryMatch = z
242
+ .object({
243
+ class: WorkDiscoveryMatchClass,
244
+ field: WorkDiscoveryMatchedField,
245
+ scoreBand: WorkDiscoveryScoreBand,
246
+ claimId: z.string().uuid().nullable(),
247
+ })
248
+ .strict();
249
+ export type WorkDiscoveryMatch = z.infer<typeof WorkDiscoveryMatch>;
250
+
251
+ /**
252
+ * Provider-neutral related-work evidence. The two literal booleans are part of
253
+ * the wire contract so a consumer cannot accidentally present a claim as a
254
+ * lock, authorization grant, ownership transfer, or mandatory instruction.
255
+ */
256
+ export const WorkDiscoveryProjection = z
257
+ .object({
258
+ claims: z.array(WorkClaimDiscoverySummary).max(WORK_CLAIM_DISCOVERY_LIMIT),
259
+ claimsTruncated: z.boolean(),
260
+ match: WorkDiscoveryMatch.nullable(),
261
+ possibleOverlap: z.boolean(),
262
+ advisoryOnly: z.literal(true),
263
+ noAdditionalAccess: z.literal(true),
264
+ })
265
+ .strict();
266
+ export type WorkDiscoveryProjection = z.infer<typeof WorkDiscoveryProjection>;