@stigmer/sdk 3.12.5 → 3.12.7

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.
Files changed (175) hide show
  1. package/__tests__/update-input-roundtrip.test.d.ts +2 -0
  2. package/__tests__/update-input-roundtrip.test.d.ts.map +1 -0
  3. package/__tests__/update-input-roundtrip.test.js +795 -0
  4. package/__tests__/update-input-roundtrip.test.js.map +1 -0
  5. package/__tests__/update-input.test.js +22 -3
  6. package/__tests__/update-input.test.js.map +1 -1
  7. package/execution/__tests__/transcript.test.d.ts +2 -0
  8. package/execution/__tests__/transcript.test.d.ts.map +1 -0
  9. package/execution/__tests__/transcript.test.js +527 -0
  10. package/execution/__tests__/transcript.test.js.map +1 -0
  11. package/execution/conversation-rules.d.ts +64 -0
  12. package/execution/conversation-rules.d.ts.map +1 -0
  13. package/execution/conversation-rules.js +113 -0
  14. package/execution/conversation-rules.js.map +1 -0
  15. package/execution/transcript.d.ts +171 -0
  16. package/execution/transcript.d.ts.map +1 -0
  17. package/execution/transcript.js +484 -0
  18. package/execution/transcript.js.map +1 -0
  19. package/gen/agent.d.ts +21 -0
  20. package/gen/agent.d.ts.map +1 -1
  21. package/gen/agent.js +73 -1
  22. package/gen/agent.js.map +1 -1
  23. package/gen/agentchannel.d.ts +23 -1
  24. package/gen/agentchannel.d.ts.map +1 -1
  25. package/gen/agentchannel.js +55 -1
  26. package/gen/agentchannel.js.map +1 -1
  27. package/gen/agentexecution.d.ts +34 -1
  28. package/gen/agentexecution.d.ts.map +1 -1
  29. package/gen/agentexecution.js +176 -2
  30. package/gen/agentexecution.js.map +1 -1
  31. package/gen/agentinstance.d.ts +21 -0
  32. package/gen/agentinstance.d.ts.map +1 -1
  33. package/gen/agentinstance.js +32 -1
  34. package/gen/agentinstance.js.map +1 -1
  35. package/gen/agentshare.d.ts +23 -1
  36. package/gen/agentshare.d.ts.map +1 -1
  37. package/gen/agentshare.js +53 -1
  38. package/gen/agentshare.js.map +1 -1
  39. package/gen/apikey.d.ts +21 -0
  40. package/gen/apikey.d.ts.map +1 -1
  41. package/gen/apikey.js +33 -1
  42. package/gen/apikey.js.map +1 -1
  43. package/gen/artifact.d.ts +8 -0
  44. package/gen/artifact.d.ts.map +1 -1
  45. package/gen/artifact.js +1 -0
  46. package/gen/artifact.js.map +1 -1
  47. package/gen/channelapp.d.ts +21 -0
  48. package/gen/channelapp.d.ts.map +1 -1
  49. package/gen/channelapp.js +45 -0
  50. package/gen/channelapp.js.map +1 -1
  51. package/gen/client.d.ts +5 -1
  52. package/gen/client.d.ts.map +1 -1
  53. package/gen/client.js +4 -0
  54. package/gen/client.js.map +1 -1
  55. package/gen/environment.d.ts +21 -0
  56. package/gen/environment.d.ts.map +1 -1
  57. package/gen/environment.js +31 -1
  58. package/gen/environment.js.map +1 -1
  59. package/gen/executioncontext.d.ts +8 -0
  60. package/gen/executioncontext.d.ts.map +1 -1
  61. package/gen/executioncontext.js +1 -0
  62. package/gen/executioncontext.js.map +1 -1
  63. package/gen/iampolicy.d.ts +8 -0
  64. package/gen/iampolicy.d.ts.map +1 -1
  65. package/gen/iampolicy.js +1 -0
  66. package/gen/iampolicy.js.map +1 -1
  67. package/gen/identityaccount.d.ts +22 -0
  68. package/gen/identityaccount.d.ts.map +1 -1
  69. package/gen/identityaccount.js +48 -1
  70. package/gen/identityaccount.js.map +1 -1
  71. package/gen/identityprovider.d.ts +21 -0
  72. package/gen/identityprovider.d.ts.map +1 -1
  73. package/gen/identityprovider.js +40 -0
  74. package/gen/identityprovider.js.map +1 -1
  75. package/gen/invitation.d.ts +8 -0
  76. package/gen/invitation.d.ts.map +1 -1
  77. package/gen/invitation.js +1 -0
  78. package/gen/invitation.js.map +1 -1
  79. package/gen/mcpserver.d.ts +21 -0
  80. package/gen/mcpserver.d.ts.map +1 -1
  81. package/gen/mcpserver.js +79 -1
  82. package/gen/mcpserver.js.map +1 -1
  83. package/gen/memory.d.ts +58 -0
  84. package/gen/memory.d.ts.map +1 -0
  85. package/gen/memory.js +143 -0
  86. package/gen/memory.js.map +1 -0
  87. package/gen/oauthapp.d.ts +21 -0
  88. package/gen/oauthapp.d.ts.map +1 -1
  89. package/gen/oauthapp.js +39 -0
  90. package/gen/oauthapp.js.map +1 -1
  91. package/gen/organization.d.ts +22 -0
  92. package/gen/organization.d.ts.map +1 -1
  93. package/gen/organization.js +43 -1
  94. package/gen/organization.js.map +1 -1
  95. package/gen/platformclient.d.ts +21 -0
  96. package/gen/platformclient.d.ts.map +1 -1
  97. package/gen/platformclient.js +40 -1
  98. package/gen/platformclient.js.map +1 -1
  99. package/gen/project.d.ts +21 -0
  100. package/gen/project.d.ts.map +1 -1
  101. package/gen/project.js +32 -1
  102. package/gen/project.js.map +1 -1
  103. package/gen/proto-utils.d.ts +36 -0
  104. package/gen/proto-utils.d.ts.map +1 -1
  105. package/gen/proto-utils.js +58 -0
  106. package/gen/proto-utils.js.map +1 -1
  107. package/gen/schedule.d.ts +23 -1
  108. package/gen/schedule.d.ts.map +1 -1
  109. package/gen/schedule.js +79 -1
  110. package/gen/schedule.js.map +1 -1
  111. package/gen/session.d.ts +21 -0
  112. package/gen/session.d.ts.map +1 -1
  113. package/gen/session.js +80 -1
  114. package/gen/session.js.map +1 -1
  115. package/gen/skill.d.ts +8 -0
  116. package/gen/skill.d.ts.map +1 -1
  117. package/gen/skill.js +1 -0
  118. package/gen/skill.js.map +1 -1
  119. package/gen/workflow.d.ts +21 -0
  120. package/gen/workflow.d.ts.map +1 -1
  121. package/gen/workflow.js +79 -0
  122. package/gen/workflow.js.map +1 -1
  123. package/gen/workflowexecution.d.ts +21 -0
  124. package/gen/workflowexecution.d.ts.map +1 -1
  125. package/gen/workflowexecution.js +36 -1
  126. package/gen/workflowexecution.js.map +1 -1
  127. package/gen/workflowinstance.d.ts +21 -0
  128. package/gen/workflowinstance.d.ts.map +1 -1
  129. package/gen/workflowinstance.js +33 -1
  130. package/gen/workflowinstance.js.map +1 -1
  131. package/index.d.ts +23 -21
  132. package/index.d.ts.map +1 -1
  133. package/index.js +27 -23
  134. package/index.js.map +1 -1
  135. package/package.json +2 -2
  136. package/src/__tests__/update-input-roundtrip.test.ts +1035 -0
  137. package/src/__tests__/update-input.test.ts +34 -3
  138. package/src/execution/__tests__/transcript.golden.md +100 -0
  139. package/src/execution/__tests__/transcript.test.ts +627 -0
  140. package/src/execution/conversation-rules.ts +119 -0
  141. package/src/execution/transcript.ts +735 -0
  142. package/src/gen/agent.ts +89 -3
  143. package/src/gen/agentchannel.ts +72 -4
  144. package/src/gen/agentexecution.ts +216 -6
  145. package/src/gen/agentinstance.ts +41 -1
  146. package/src/gen/agentshare.ts +68 -4
  147. package/src/gen/apikey.ts +42 -1
  148. package/src/gen/artifact.ts +9 -0
  149. package/src/gen/channelapp.ts +57 -1
  150. package/src/gen/client.ts +6 -1
  151. package/src/gen/environment.ts +40 -1
  152. package/src/gen/executioncontext.ts +9 -0
  153. package/src/gen/iampolicy.ts +9 -0
  154. package/src/gen/identityaccount.ts +60 -2
  155. package/src/gen/identityprovider.ts +49 -0
  156. package/src/gen/invitation.ts +9 -0
  157. package/src/gen/mcpserver.ts +95 -3
  158. package/src/gen/memory.ts +164 -0
  159. package/src/gen/oauthapp.ts +48 -0
  160. package/src/gen/organization.ts +55 -2
  161. package/src/gen/platformclient.ts +49 -1
  162. package/src/gen/project.ts +41 -1
  163. package/src/gen/proto-utils.ts +64 -0
  164. package/src/gen/schedule.ts +98 -4
  165. package/src/gen/session.ts +97 -3
  166. package/src/gen/skill.ts +9 -0
  167. package/src/gen/workflow.ts +96 -2
  168. package/src/gen/workflowexecution.ts +45 -1
  169. package/src/gen/workflowinstance.ts +42 -1
  170. package/src/index.ts +52 -9
  171. package/src/update-input.ts +0 -168
  172. package/update-input.d.ts +0 -24
  173. package/update-input.d.ts.map +0 -1
  174. package/update-input.js +0 -126
  175. package/update-input.js.map +0 -1
package/src/index.ts CHANGED
@@ -61,12 +61,6 @@ export {
61
61
  isResourceAvailable,
62
62
  } from "./resource-availability.js";
63
63
 
64
- // Complete update-input mappers (full-spec-replace round-trip safety)
65
- export {
66
- toOrganizationUpdateInput,
67
- toIdentityAccountUpdateInput,
68
- } from "./update-input.js";
69
-
70
64
  // Authorization config and IAM role utilities
71
65
  export {
72
66
  getGrantableRoles,
@@ -166,10 +160,14 @@ export {
166
160
  type EnvVarInput,
167
161
  } from "./gen/types.js";
168
162
 
169
- // Re-export all resource client classes and input types
163
+ // Re-export all resource client classes and input types. The
164
+ // toXxxUpdateInput mappers are the full-spec-replace safety layer: they
165
+ // rebuild a COMPLETE input from a fetched resource so subset editors can
166
+ // spread-and-override without wiping unlisted fields.
170
167
  export {
171
168
  AgentClient,
172
169
  buildAgentProto,
170
+ toAgentUpdateInput,
173
171
  type AgentInput,
174
172
  type McpServerUsageInput,
175
173
  type ToolApprovalOverrideInput,
@@ -179,11 +177,13 @@ export {
179
177
  } from "./gen/agent.js";
180
178
  export {
181
179
  AgentChannelClient,
180
+ toAgentChannelUpdateInput,
182
181
  type AgentChannelInput,
183
182
  type SlackChannelConfigInput,
184
183
  } from "./gen/agentchannel.js";
185
184
  export {
186
185
  AgentExecutionClient,
186
+ toAgentExecutionUpdateInput,
187
187
  type AgentExecutionInput,
188
188
  type ExecutionConfigInput,
189
189
  type ContextManagementConfigInput,
@@ -191,21 +191,25 @@ export {
191
191
  } from "./gen/agentexecution.js";
192
192
  export {
193
193
  AgentInstanceClient,
194
+ toAgentInstanceUpdateInput,
194
195
  type AgentInstanceInput,
195
196
  } from "./gen/agentinstance.js";
196
197
  export {
197
198
  AgentShareClient,
199
+ toAgentShareUpdateInput,
198
200
  type AgentShareInput,
199
201
  type AgentShareMessagesInput,
200
202
  } from "./gen/agentshare.js";
201
- export { ApiKeyClient, type ApiKeyInput } from "./gen/apikey.js";
203
+ export { ApiKeyClient, toApiKeyUpdateInput, type ApiKeyInput } from "./gen/apikey.js";
202
204
  export {
203
205
  ChannelAppClient,
206
+ toChannelAppUpdateInput,
204
207
  type ChannelAppInput,
205
208
  type SlackChannelAppConfigInput,
206
209
  } from "./gen/channelapp.js";
207
210
  export {
208
211
  EnvironmentClient,
212
+ toEnvironmentUpdateInput,
209
213
  type EnvironmentInput,
210
214
  } from "./gen/environment.js";
211
215
  export {
@@ -219,6 +223,7 @@ export {
219
223
  } from "./gen/iampolicy.js";
220
224
  export {
221
225
  IdentityAccountClient,
226
+ toIdentityAccountUpdateInput,
222
227
  type IdentityAccountInput,
223
228
  } from "./gen/identityaccount.js";
224
229
  export {
@@ -227,20 +232,30 @@ export {
227
232
  } from "./gen/invitation.js";
228
233
  export {
229
234
  IdentityProviderClient,
235
+ toIdentityProviderUpdateInput,
230
236
  type IdentityProviderInput,
231
237
  } from "./gen/identityprovider.js";
232
238
  export {
233
239
  OAuthAppClient,
240
+ toOAuthAppUpdateInput,
234
241
  type OAuthAppInput,
235
242
  } from "./gen/oauthapp.js";
236
243
  export {
237
244
  McpServerClient,
238
245
  buildMcpServerProto,
246
+ toMcpServerUpdateInput,
239
247
  type McpServerInput,
240
248
  type StdioServerConfigInput,
241
249
  type HttpServerConfigInput,
242
250
  type ToolApprovalPolicyInput,
243
251
  } from "./gen/mcpserver.js";
252
+ export {
253
+ MemoryClient,
254
+ buildMemoryProto,
255
+ toMemoryUpdateInput,
256
+ type MemoryInput,
257
+ type MemoryProvenanceInput,
258
+ } from "./gen/memory.js";
244
259
  export {
245
260
  connectAndWait,
246
261
  ConnectStillRunningError,
@@ -251,22 +266,26 @@ export {
251
266
  } from "./mcpserver-connect.js";
252
267
  export {
253
268
  OrganizationClient,
269
+ toOrganizationUpdateInput,
254
270
  type OrganizationInput,
255
271
  } from "./gen/organization.js";
256
272
  export {
257
273
  PlatformClientClient,
274
+ toPlatformClientUpdateInput,
258
275
  type PlatformClientInput,
259
276
  } from "./gen/platformclient.js";
260
- export { ProjectClient, type ProjectInput } from "./gen/project.js";
277
+ export { ProjectClient, toProjectUpdateInput, type ProjectInput } from "./gen/project.js";
261
278
  export {
262
279
  ScheduleClient,
263
280
  buildScheduleProto,
281
+ toScheduleUpdateInput,
264
282
  type ScheduleInput,
265
283
  type AgentInvocationInput,
266
284
  type RunConfigInput,
267
285
  } from "./gen/schedule.js";
268
286
  export {
269
287
  SessionClient,
288
+ toSessionUpdateInput,
270
289
  type SessionInput,
271
290
  type WorkspaceEntryInput,
272
291
  type WorkspaceSourceInput,
@@ -302,6 +321,27 @@ export {
302
321
  isInformativePolicySource,
303
322
  } from "./execution/approval-provenance.js";
304
323
  export { isTerminalPhase } from "./execution/execution-phases.js";
324
+ export {
325
+ sortChronologically,
326
+ supersededExecutionIds,
327
+ isBuildFromPlanTurn,
328
+ syntheticUserPrompt,
329
+ execIdFromStorageKey,
330
+ } from "./execution/conversation-rules.js";
331
+ export {
332
+ assembleSessionTranscript,
333
+ fetchSessionTranscript,
334
+ resolveOffloadedOutputs,
335
+ transcriptToMarkdown,
336
+ transcriptToJson,
337
+ type SessionTranscript,
338
+ type TranscriptTurn,
339
+ type ResolvedToolOutput,
340
+ type SessionTranscriptClient,
341
+ type AssembleSessionTranscriptOptions,
342
+ type FetchSessionTranscriptOptions,
343
+ type TranscriptToMarkdownOptions,
344
+ } from "./execution/transcript.js";
305
345
  export {
306
346
  foldFileReviewEventStream,
307
347
  displayFileChangeSets,
@@ -311,6 +351,7 @@ export { SkillClient, type SkillInput } from "./gen/skill.js";
311
351
  export { RoutedSkillClient, MAX_INLINE_ARTIFACT_BYTES } from "./skill.js";
312
352
  export {
313
353
  WorkflowClient,
354
+ toWorkflowUpdateInput,
314
355
  type WorkflowInput,
315
356
  type WorkflowDocumentInput,
316
357
  type WorkflowTaskInput,
@@ -319,9 +360,11 @@ export {
319
360
  } from "./gen/workflow.js";
320
361
  export {
321
362
  WorkflowExecutionClient,
363
+ toWorkflowExecutionUpdateInput,
322
364
  type WorkflowExecutionInput,
323
365
  } from "./gen/workflowexecution.js";
324
366
  export {
325
367
  WorkflowInstanceClient,
368
+ toWorkflowInstanceUpdateInput,
326
369
  type WorkflowInstanceInput,
327
370
  } from "./gen/workflowinstance.js";
@@ -1,168 +0,0 @@
1
- // Complete update-input mappers.
2
- //
3
- // The platform's update RPCs are FULL-SPEC REPLACEMENTS: the request spec
4
- // wholesale overwrites the stored spec (both editions; only a small
5
- // server-side preserve list of immutable identifiers survives). A client
6
- // that sends only the fields it edits therefore silently WIPES every other
7
- // mutable spec field — a data-loss bug class, not a single bug
8
- // (stigmer/stigmer#293 Phase 1 surfaced it when `spec.preferences` set via
9
- // CLI was dropped by a console profile save).
10
- //
11
- // These mappers are the structural fix: they convert a LOADED resource into
12
- // a complete `*Input` for the generated update builders. Editors spread the
13
- // mapper output and override only the fields they edit:
14
- //
15
- // await update({ ...toOrganizationUpdateInput(org), description: next });
16
- //
17
- // The `CompleteInput` mapped type removes optionality from every Input key,
18
- // so when codegen adds a new Input field, compilation fails HERE — the one
19
- // place a human must decide how the new field round-trips — instead of the
20
- // field silently wiping in every subset-editing form.
21
- //
22
- // NESTED MESSAGE RULE: `CompleteInput` only sees TOP-LEVEL keys — a nested
23
- // message (e.g. `preferences`) is one key whose object literal would keep
24
- // compiling when codegen adds fields INSIDE it, recreating the wipe bug one
25
- // level down. Every nested-message literal in this file must therefore be
26
- // built by a dedicated `toXxxInput` helper whose return literal is itself
27
- // typed `CompleteInput<XxxInput>`. Editors that override a nested message
28
- // must spread the mapper's complete value and override only their fields:
29
- //
30
- // preferences: { ...mapped.preferences, standingContext: next }
31
-
32
- import type { ApiResourceReference } from "@stigmer/protos/ai/stigmer/commons/apiresource/io_pb";
33
- import type { IdentityAccount } from "@stigmer/protos/ai/stigmer/iam/identityaccount/v1/api_pb";
34
- import type { IdentityAccountPreferences } from "@stigmer/protos/ai/stigmer/iam/identityaccount/v1/spec_pb";
35
- import type { Organization } from "@stigmer/protos/ai/stigmer/tenancy/organization/v1/api_pb";
36
- import type { OrganizationPreferences } from "@stigmer/protos/ai/stigmer/tenancy/organization/v1/spec_pb";
37
- import type {
38
- IdentityAccountInput,
39
- IdentityAccountPreferencesInput,
40
- } from "./gen/identityaccount.js";
41
- import type {
42
- OrganizationInput,
43
- OrganizationPreferencesInput,
44
- } from "./gen/organization.js";
45
- import type { ResourceRef } from "./gen/types.js";
46
-
47
- /**
48
- * Every key of `T`, required to be present. Optional keys keep their
49
- * `| undefined` value type (explicit `undefined` is stripped by the proto
50
- * builders), so a mapper cannot compile while omitting an Input field.
51
- *
52
- * Mapping over `keyof Required<T>` (instead of a homomorphic `-?` map)
53
- * is deliberate: `-?` would also strip `undefined` from optional value
54
- * types, forcing fake values for genuinely absent fields.
55
- */
56
- type CompleteInput<T> = { [K in keyof Required<T>]: T[K] };
57
-
58
- /**
59
- * Maps a loaded {@link Organization} to a complete {@link OrganizationInput}
60
- * for `organization.update()`.
61
- *
62
- * Proto3 scalar defaults (empty string, `false`, enum `0`) are normalized to
63
- * `undefined` — omitting them is wire-identical to sending the default, and
64
- * it keeps the built proto in the builders' canonical shape.
65
- */
66
- export function toOrganizationUpdateInput(
67
- org: Organization,
68
- ): OrganizationInput {
69
- const input: CompleteInput<OrganizationInput> = {
70
- name: org.metadata?.name ?? "",
71
- slug: org.metadata?.slug || undefined,
72
- org: org.metadata?.org || org.metadata?.slug || "",
73
- labels: nonEmptyLabels(org.metadata?.labels),
74
- visibility: org.metadata?.visibility || undefined,
75
- description: org.spec?.description || undefined,
76
- logoUrl: org.spec?.logoUrl || undefined,
77
- managementMode: org.spec?.managementMode || undefined,
78
- identityProviderRef: toResourceRef(org.spec?.identityProviderRef),
79
- externalOrgId: org.spec?.externalOrgId || undefined,
80
- isPersonal: org.spec?.isPersonal || undefined,
81
- preferences: org.spec?.preferences
82
- ? toOrganizationPreferencesInput(org.spec.preferences)
83
- : undefined,
84
- };
85
- return input;
86
- }
87
-
88
- /**
89
- * Maps loaded {@link OrganizationPreferences} to a complete
90
- * {@link OrganizationPreferencesInput} (nested-message rule above).
91
- */
92
- function toOrganizationPreferencesInput(
93
- preferences: OrganizationPreferences,
94
- ): OrganizationPreferencesInput {
95
- const input: CompleteInput<OrganizationPreferencesInput> = {
96
- standingContext: preferences.standingContext || undefined,
97
- };
98
- return input;
99
- }
100
-
101
- /**
102
- * Maps a loaded {@link IdentityAccount} to a complete
103
- * {@link IdentityAccountInput} for `identityAccount.update()`.
104
- *
105
- * The generated builder never sets `metadata.id`; the update pipeline
106
- * locates the resource by org + slug instead (and authorizes against the
107
- * loaded resource's id), so carrying `org` and `slug` here is what makes
108
- * the update addressable.
109
- */
110
- export function toIdentityAccountUpdateInput(
111
- account: IdentityAccount,
112
- ): IdentityAccountInput {
113
- const input: CompleteInput<IdentityAccountInput> = {
114
- name: account.metadata?.name ?? "",
115
- slug: account.metadata?.slug || undefined,
116
- org: account.metadata?.org ?? "",
117
- labels: nonEmptyLabels(account.metadata?.labels),
118
- visibility: account.metadata?.visibility || undefined,
119
- idpId: account.spec?.idpId ?? "",
120
- email: account.spec?.email || undefined,
121
- firstName: account.spec?.firstName || undefined,
122
- lastName: account.spec?.lastName || undefined,
123
- pictureUrl: account.spec?.pictureUrl || undefined,
124
- isMachineAccount: account.spec?.isMachineAccount || undefined,
125
- provisioningMode: account.spec?.provisioningMode || undefined,
126
- identityProviderRef: toResourceRef(account.spec?.identityProviderRef),
127
- preferences: account.spec?.preferences
128
- ? toIdentityAccountPreferencesInput(account.spec.preferences)
129
- : undefined,
130
- };
131
- return input;
132
- }
133
-
134
- /**
135
- * Maps loaded {@link IdentityAccountPreferences} to a complete
136
- * {@link IdentityAccountPreferencesInput} (nested-message rule above).
137
- */
138
- function toIdentityAccountPreferencesInput(
139
- preferences: IdentityAccountPreferences,
140
- ): IdentityAccountPreferencesInput {
141
- const input: CompleteInput<IdentityAccountPreferencesInput> = {
142
- standingContext: preferences.standingContext || undefined,
143
- defaultHarness: preferences.defaultHarness || undefined,
144
- defaultNativeModel: preferences.defaultNativeModel || undefined,
145
- defaultCursorModel: preferences.defaultCursorModel || undefined,
146
- };
147
- return input;
148
- }
149
-
150
- function nonEmptyLabels(
151
- labels: Record<string, string> | undefined,
152
- ): Record<string, string> | undefined {
153
- return labels && Object.keys(labels).length > 0 ? labels : undefined;
154
- }
155
-
156
- function toResourceRef(
157
- ref: ApiResourceReference | undefined,
158
- ): ResourceRef | undefined {
159
- // The builders treat a ref without org and slug as absent; mirror that so
160
- // an empty message round-trips to "no reference".
161
- if (!ref || (!ref.org && !ref.slug)) return undefined;
162
- return {
163
- org: ref.org,
164
- slug: ref.slug,
165
- ...(ref.version && { version: ref.version }),
166
- ...(ref.kind && { kind: ref.kind }),
167
- };
168
- }
package/update-input.d.ts DELETED
@@ -1,24 +0,0 @@
1
- import type { IdentityAccount } from "@stigmer/protos/ai/stigmer/iam/identityaccount/v1/api_pb";
2
- import type { Organization } from "@stigmer/protos/ai/stigmer/tenancy/organization/v1/api_pb";
3
- import type { IdentityAccountInput } from "./gen/identityaccount.js";
4
- import type { OrganizationInput } from "./gen/organization.js";
5
- /**
6
- * Maps a loaded {@link Organization} to a complete {@link OrganizationInput}
7
- * for `organization.update()`.
8
- *
9
- * Proto3 scalar defaults (empty string, `false`, enum `0`) are normalized to
10
- * `undefined` — omitting them is wire-identical to sending the default, and
11
- * it keeps the built proto in the builders' canonical shape.
12
- */
13
- export declare function toOrganizationUpdateInput(org: Organization): OrganizationInput;
14
- /**
15
- * Maps a loaded {@link IdentityAccount} to a complete
16
- * {@link IdentityAccountInput} for `identityAccount.update()`.
17
- *
18
- * The generated builder never sets `metadata.id`; the update pipeline
19
- * locates the resource by org + slug instead (and authorizes against the
20
- * loaded resource's id), so carrying `org` and `slug` here is what makes
21
- * the update addressable.
22
- */
23
- export declare function toIdentityAccountUpdateInput(account: IdentityAccount): IdentityAccountInput;
24
- //# sourceMappingURL=update-input.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"update-input.d.ts","sourceRoot":"","sources":["../src/update-input.ts"],"names":[],"mappings":"AAgCA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0DAA0D,CAAC;AAEhG,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2DAA2D,CAAC;AAE9F,OAAO,KAAK,EACV,oBAAoB,EAErB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EACV,iBAAiB,EAElB,MAAM,uBAAuB,CAAC;AAc/B;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CACvC,GAAG,EAAE,YAAY,GAChB,iBAAiB,CAkBnB;AAeD;;;;;;;;GAQG;AACH,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,eAAe,GACvB,oBAAoB,CAoBtB"}
package/update-input.js DELETED
@@ -1,126 +0,0 @@
1
- // Complete update-input mappers.
2
- //
3
- // The platform's update RPCs are FULL-SPEC REPLACEMENTS: the request spec
4
- // wholesale overwrites the stored spec (both editions; only a small
5
- // server-side preserve list of immutable identifiers survives). A client
6
- // that sends only the fields it edits therefore silently WIPES every other
7
- // mutable spec field — a data-loss bug class, not a single bug
8
- // (stigmer/stigmer#293 Phase 1 surfaced it when `spec.preferences` set via
9
- // CLI was dropped by a console profile save).
10
- //
11
- // These mappers are the structural fix: they convert a LOADED resource into
12
- // a complete `*Input` for the generated update builders. Editors spread the
13
- // mapper output and override only the fields they edit:
14
- //
15
- // await update({ ...toOrganizationUpdateInput(org), description: next });
16
- //
17
- // The `CompleteInput` mapped type removes optionality from every Input key,
18
- // so when codegen adds a new Input field, compilation fails HERE — the one
19
- // place a human must decide how the new field round-trips — instead of the
20
- // field silently wiping in every subset-editing form.
21
- //
22
- // NESTED MESSAGE RULE: `CompleteInput` only sees TOP-LEVEL keys — a nested
23
- // message (e.g. `preferences`) is one key whose object literal would keep
24
- // compiling when codegen adds fields INSIDE it, recreating the wipe bug one
25
- // level down. Every nested-message literal in this file must therefore be
26
- // built by a dedicated `toXxxInput` helper whose return literal is itself
27
- // typed `CompleteInput<XxxInput>`. Editors that override a nested message
28
- // must spread the mapper's complete value and override only their fields:
29
- //
30
- // preferences: { ...mapped.preferences, standingContext: next }
31
- /**
32
- * Maps a loaded {@link Organization} to a complete {@link OrganizationInput}
33
- * for `organization.update()`.
34
- *
35
- * Proto3 scalar defaults (empty string, `false`, enum `0`) are normalized to
36
- * `undefined` — omitting them is wire-identical to sending the default, and
37
- * it keeps the built proto in the builders' canonical shape.
38
- */
39
- export function toOrganizationUpdateInput(org) {
40
- const input = {
41
- name: org.metadata?.name ?? "",
42
- slug: org.metadata?.slug || undefined,
43
- org: org.metadata?.org || org.metadata?.slug || "",
44
- labels: nonEmptyLabels(org.metadata?.labels),
45
- visibility: org.metadata?.visibility || undefined,
46
- description: org.spec?.description || undefined,
47
- logoUrl: org.spec?.logoUrl || undefined,
48
- managementMode: org.spec?.managementMode || undefined,
49
- identityProviderRef: toResourceRef(org.spec?.identityProviderRef),
50
- externalOrgId: org.spec?.externalOrgId || undefined,
51
- isPersonal: org.spec?.isPersonal || undefined,
52
- preferences: org.spec?.preferences
53
- ? toOrganizationPreferencesInput(org.spec.preferences)
54
- : undefined,
55
- };
56
- return input;
57
- }
58
- /**
59
- * Maps loaded {@link OrganizationPreferences} to a complete
60
- * {@link OrganizationPreferencesInput} (nested-message rule above).
61
- */
62
- function toOrganizationPreferencesInput(preferences) {
63
- const input = {
64
- standingContext: preferences.standingContext || undefined,
65
- };
66
- return input;
67
- }
68
- /**
69
- * Maps a loaded {@link IdentityAccount} to a complete
70
- * {@link IdentityAccountInput} for `identityAccount.update()`.
71
- *
72
- * The generated builder never sets `metadata.id`; the update pipeline
73
- * locates the resource by org + slug instead (and authorizes against the
74
- * loaded resource's id), so carrying `org` and `slug` here is what makes
75
- * the update addressable.
76
- */
77
- export function toIdentityAccountUpdateInput(account) {
78
- const input = {
79
- name: account.metadata?.name ?? "",
80
- slug: account.metadata?.slug || undefined,
81
- org: account.metadata?.org ?? "",
82
- labels: nonEmptyLabels(account.metadata?.labels),
83
- visibility: account.metadata?.visibility || undefined,
84
- idpId: account.spec?.idpId ?? "",
85
- email: account.spec?.email || undefined,
86
- firstName: account.spec?.firstName || undefined,
87
- lastName: account.spec?.lastName || undefined,
88
- pictureUrl: account.spec?.pictureUrl || undefined,
89
- isMachineAccount: account.spec?.isMachineAccount || undefined,
90
- provisioningMode: account.spec?.provisioningMode || undefined,
91
- identityProviderRef: toResourceRef(account.spec?.identityProviderRef),
92
- preferences: account.spec?.preferences
93
- ? toIdentityAccountPreferencesInput(account.spec.preferences)
94
- : undefined,
95
- };
96
- return input;
97
- }
98
- /**
99
- * Maps loaded {@link IdentityAccountPreferences} to a complete
100
- * {@link IdentityAccountPreferencesInput} (nested-message rule above).
101
- */
102
- function toIdentityAccountPreferencesInput(preferences) {
103
- const input = {
104
- standingContext: preferences.standingContext || undefined,
105
- defaultHarness: preferences.defaultHarness || undefined,
106
- defaultNativeModel: preferences.defaultNativeModel || undefined,
107
- defaultCursorModel: preferences.defaultCursorModel || undefined,
108
- };
109
- return input;
110
- }
111
- function nonEmptyLabels(labels) {
112
- return labels && Object.keys(labels).length > 0 ? labels : undefined;
113
- }
114
- function toResourceRef(ref) {
115
- // The builders treat a ref without org and slug as absent; mirror that so
116
- // an empty message round-trips to "no reference".
117
- if (!ref || (!ref.org && !ref.slug))
118
- return undefined;
119
- return {
120
- org: ref.org,
121
- slug: ref.slug,
122
- ...(ref.version && { version: ref.version }),
123
- ...(ref.kind && { kind: ref.kind }),
124
- };
125
- }
126
- //# sourceMappingURL=update-input.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"update-input.js","sourceRoot":"","sources":["../src/update-input.ts"],"names":[],"mappings":"AAAA,iCAAiC;AACjC,EAAE;AACF,0EAA0E;AAC1E,oEAAoE;AACpE,yEAAyE;AACzE,2EAA2E;AAC3E,+DAA+D;AAC/D,2EAA2E;AAC3E,8CAA8C;AAC9C,EAAE;AACF,4EAA4E;AAC5E,4EAA4E;AAC5E,wDAAwD;AACxD,EAAE;AACF,4EAA4E;AAC5E,EAAE;AACF,4EAA4E;AAC5E,2EAA2E;AAC3E,2EAA2E;AAC3E,sDAAsD;AACtD,EAAE;AACF,2EAA2E;AAC3E,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