@akagilnc/pi-workflow-roles 0.1.3708 → 0.1.3716

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 (37) hide show
  1. package/README.md +4 -0
  2. package/README.zh-CN.md +4 -0
  3. package/dist/acp-host/production-host.js +262 -518
  4. package/dist/adr-path-refs.js +1 -1
  5. package/dist/diarist-contracts.js +31 -21
  6. package/dist/diarist-role.js +17 -8
  7. package/dist/diarist.js +39 -388
  8. package/dist/package-contracts/terminating-tools.js +1 -1
  9. package/dist/packaged-role-registry.js +4 -8
  10. package/dist/pi/role-turn-host.js +1 -7
  11. package/dist/public-cli/config.js +106 -2
  12. package/dist/public-cli/main.js +263 -1488
  13. package/dist/public-cli/option-definitions.js +3 -0
  14. package/dist/role-runtime.js +60 -88
  15. package/dist/ticket-provenance-contracts.js +0 -5
  16. package/dist/ticket-provenance.js +2 -149
  17. package/package.json +1 -1
  18. package/resources/diarist-collect.md +21 -11
  19. package/src/acp-host/role-envelope.ts +1 -1
  20. package/src/adr-path-refs.ts +1 -1
  21. package/src/diarist-contracts.ts +48 -32
  22. package/src/diarist-role.ts +31 -16
  23. package/src/diarist.ts +54 -635
  24. package/src/host-contracts.ts +1 -5
  25. package/src/package-contracts/terminating-tools.ts +1 -1
  26. package/src/packaged-role-registry.ts +4 -8
  27. package/src/pi/role-turn-host.ts +1 -7
  28. package/src/public-cli/cli.ts +54 -0
  29. package/src/public-cli/config.ts +157 -1
  30. package/src/public-cli/countersign-run.ts +2 -3
  31. package/src/public-cli/diarist-run.ts +15 -117
  32. package/src/public-cli/option-definitions.ts +3 -0
  33. package/src/role-runtime.ts +73 -105
  34. package/src/ticket-provenance-contracts.ts +6 -12
  35. package/src/ticket-provenance.ts +1 -207
  36. package/dist/diarist-mechanical.js +0 -411
  37. package/src/diarist-mechanical.ts +0 -571
@@ -139,6 +139,50 @@ function parseAutoResumeLimit(value) {
139
139
  function setAutoResumeLimit(config, limit) {
140
140
  return { ...config, autoResumeLimit: parseAutoResumeLimit(limit) };
141
141
  }
142
+ function requireNonEmptyToken(value, label) {
143
+ const trimmed = value.trim();
144
+ if (trimmed === "") {
145
+ throw new Error(`${label} must be a non-empty string`);
146
+ }
147
+ return trimmed;
148
+ }
149
+ function setProviderHostAlias(config, provider, host, alias) {
150
+ const from = requireNonEmptyToken(provider, "provider");
151
+ const hostName = requireNonEmptyToken(host, "host");
152
+ const to = requireNonEmptyToken(alias, "alias");
153
+ const previous = config.providerAliases ?? {};
154
+ return {
155
+ ...config,
156
+ providerAliases: {
157
+ ...previous,
158
+ [from]: {
159
+ ...previous[from] ?? {},
160
+ [hostName]: to
161
+ }
162
+ }
163
+ };
164
+ }
165
+ function unsetProviderHostAlias(config, provider, host) {
166
+ const from = requireNonEmptyToken(provider, "provider");
167
+ const hostName = requireNonEmptyToken(host, "host");
168
+ const previous = config.providerAliases;
169
+ if (previous === void 0 || previous[from] === void 0) return config;
170
+ const { [hostName]: _dropped, ...restHosts } = previous[from];
171
+ const nextForProvider = Object.keys(restHosts).length === 0 ? void 0 : restHosts;
172
+ const { [from]: _provider, ...restProviders } = previous;
173
+ const nextAliases = nextForProvider === void 0 ? restProviders : { ...restProviders, [from]: nextForProvider };
174
+ if (Object.keys(nextAliases).length === 0) {
175
+ const { providerAliases: _gone, ...rest } = config;
176
+ return rest;
177
+ }
178
+ return { ...config, providerAliases: nextAliases };
179
+ }
180
+ function applyProviderHostAlias(selection, host, aliases) {
181
+ if (selection === void 0 || aliases === void 0) return selection;
182
+ const mapped = aliases[selection.provider]?.[host];
183
+ if (mapped === void 0) return selection;
184
+ return { ...selection, provider: mapped };
185
+ }
142
186
  function validatePublicCliConfigAxes(config, _packageRoot) {
143
187
  for (const seat of Object.keys(config.seats)) {
144
188
  const row = config.seats[seat];
@@ -208,9 +252,44 @@ function serializePublicCliConfig(config) {
208
252
  ...config.unknownSeats ?? {},
209
253
  ...config.seats
210
254
  },
211
- ...config.autoResumeLimit === void 0 ? {} : { autoResumeLimit: config.autoResumeLimit }
255
+ ...config.autoResumeLimit === void 0 ? {} : { autoResumeLimit: config.autoResumeLimit },
256
+ ...config.providerAliases === void 0 || Object.keys(config.providerAliases).length === 0 ? {} : { providerAliases: config.providerAliases }
212
257
  };
213
258
  }
259
+ function parseProviderHostAliases(value) {
260
+ if (value === null || typeof value !== "object" || Array.isArray(value)) {
261
+ throw new Error("public CLI config.providerAliases must be an object");
262
+ }
263
+ const out = {};
264
+ for (const [provider, byHost] of Object.entries(value)) {
265
+ if (provider.trim() === "") {
266
+ throw new Error("public CLI config.providerAliases provider key must be non-empty");
267
+ }
268
+ if (byHost === null || typeof byHost !== "object" || Array.isArray(byHost)) {
269
+ throw new Error(
270
+ `public CLI config.providerAliases[${provider}] must be an object`
271
+ );
272
+ }
273
+ const hosts = {};
274
+ for (const [host, alias] of Object.entries(byHost)) {
275
+ if (host.trim() === "") {
276
+ throw new Error(
277
+ `public CLI config.providerAliases[${provider}] host key must be non-empty`
278
+ );
279
+ }
280
+ if (typeof alias !== "string" || alias.trim() === "") {
281
+ throw new Error(
282
+ `public CLI config.providerAliases[${provider}][${host}] must be a non-empty string`
283
+ );
284
+ }
285
+ hosts[host] = alias;
286
+ }
287
+ if (Object.keys(hosts).length > 0) {
288
+ out[provider] = hosts;
289
+ }
290
+ }
291
+ return out;
292
+ }
214
293
  function parsePublicCliConfig(value) {
215
294
  if (value === null || typeof value !== "object" || Array.isArray(value)) {
216
295
  throw new Error("public CLI config must be an object");
@@ -220,6 +299,13 @@ function parsePublicCliConfig(value) {
220
299
  if (record.autoResumeLimit !== void 0) {
221
300
  autoResumeLimit = parseAutoResumeLimit(record.autoResumeLimit);
222
301
  }
302
+ let providerAliases;
303
+ if (record.providerAliases !== void 0) {
304
+ const parsed = parseProviderHostAliases(record.providerAliases);
305
+ if (Object.keys(parsed).length > 0) {
306
+ providerAliases = parsed;
307
+ }
308
+ }
223
309
  const unknownSeats = {};
224
310
  if (record.unknownSeats !== void 0) {
225
311
  if (record.unknownSeats === null || typeof record.unknownSeats !== "object" || Array.isArray(record.unknownSeats)) {
@@ -230,6 +316,7 @@ function parsePublicCliConfig(value) {
230
316
  const withOpaque = (seats2) => ({
231
317
  seats: seats2,
232
318
  ...autoResumeLimit === void 0 ? {} : { autoResumeLimit },
319
+ ...providerAliases === void 0 ? {} : { providerAliases },
233
320
  ...Object.keys(unknownSeats).length === 0 ? {} : { unknownSeats }
234
321
  });
235
322
  if (record.seats === void 0) {
@@ -406,7 +493,21 @@ function resolveEffectiveSeat(config, seat, credentials, invocation) {
406
493
  };
407
494
  }
408
495
  }
409
- return attachHostAxis(attachEngineAxis(modelSeat, config, invocation), config, invocation);
496
+ const withAxes = attachHostAxis(
497
+ attachEngineAxis(modelSeat, config, invocation),
498
+ config,
499
+ invocation
500
+ );
501
+ const selection = applyProviderHostAlias(
502
+ withAxes.selection,
503
+ withAxes.host,
504
+ config.providerAliases
505
+ );
506
+ if (selection === void 0) {
507
+ const { selection: _dropped, ...rest } = withAxes;
508
+ return rest;
509
+ }
510
+ return { ...withAxes, selection };
410
511
  }
411
512
  function effectiveSeatConfigurations(config, credentials, invocation) {
412
513
  return PUBLIC_CONFIGURABLE_SEATS.map(
@@ -439,6 +540,7 @@ async function loadCredentialProviders(agentDir) {
439
540
  }
440
541
  export {
441
542
  GATE_OFFICER_SEATS,
543
+ applyProviderHostAlias,
442
544
  buildSeatModelCliArgs,
443
545
  clearPersistentSeatConfig,
444
546
  credentialProvidersFromAuthData,
@@ -459,5 +561,7 @@ export {
459
561
  setPersistentSeatConfig,
460
562
  setPersistentSeatEngine,
461
563
  setPersistentSeatHost,
564
+ setProviderHostAlias,
565
+ unsetProviderHostAlias,
462
566
  validatePublicCliConfigAxes
463
567
  };