@agentorg/cli 0.0.1 → 0.0.2

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 (90) hide show
  1. package/README.md +3 -3
  2. package/dist/src/bindings/mcp/encoding.js +1 -4
  3. package/dist/src/clients/cli/commands.js +1 -1
  4. package/dist/src/clients/cli/index.js +1 -1
  5. package/dist/src/clients/mcp/agent.d.ts +3 -5
  6. package/dist/src/clients/mcp/agent.js +10 -23
  7. package/dist/src/clients/mcp/command.d.ts +1 -1
  8. package/dist/src/clients/mcp/command.js +5 -11
  9. package/dist/src/clients/mcp/projects.d.ts +1 -2
  10. package/dist/src/clients/mcp/projects.js +5 -9
  11. package/dist/src/clients/mcp/sessions.d.ts +1 -5
  12. package/dist/src/clients/mcp/sessions.js +1 -10
  13. package/dist/src/clients/mcp/setup.js +4 -8
  14. package/dist/src/clients/mcp/waiter.d.ts +0 -2
  15. package/dist/src/clients/mcp/waiter.js +9 -20
  16. package/dist/src/domain/actors.js +3 -7
  17. package/dist/src/domain/attention.d.ts +8 -7
  18. package/dist/src/domain/attention.js +31 -47
  19. package/dist/src/domain/capabilities.js +0 -1
  20. package/dist/src/domain/claims.js +2 -2
  21. package/dist/src/domain/errors.d.ts +1 -1
  22. package/dist/src/domain/errors.js +1 -1
  23. package/dist/src/domain/index.d.ts +1 -15
  24. package/dist/src/domain/model/attention.d.ts +1 -5
  25. package/dist/src/domain/model/attention.js +5 -6
  26. package/dist/src/domain/model/builtins.d.ts +12 -179
  27. package/dist/src/domain/model/builtins.js +3 -6
  28. package/dist/src/domain/model/claims.d.ts +1 -3
  29. package/dist/src/domain/model/claims.js +1 -3
  30. package/dist/src/domain/model/index.d.ts +0 -7
  31. package/dist/src/domain/model/index.js +0 -3
  32. package/dist/src/domain/model/json-schema.d.ts +1 -4
  33. package/dist/src/domain/model/records.d.ts +0 -3
  34. package/dist/src/domain/model/records.js +3 -7
  35. package/dist/src/domain/model/system.d.ts +1 -5
  36. package/dist/src/domain/model/system.js +1 -5
  37. package/dist/src/domain/model/team.d.ts +4 -119
  38. package/dist/src/domain/model/team.js +8 -19
  39. package/dist/src/domain/model/workspace.d.ts +2 -86
  40. package/dist/src/domain/model/workspace.js +0 -1
  41. package/dist/src/domain/ports.d.ts +3 -4
  42. package/dist/src/domain/registry.d.ts +2 -16
  43. package/dist/src/domain/registry.js +22 -54
  44. package/dist/src/domain/system.js +1 -5
  45. package/dist/src/domain/team.d.ts +1 -1
  46. package/dist/src/domain/team.js +13 -33
  47. package/dist/src/domain/workspace.js +2 -10
  48. package/dist/src/home.d.ts +5 -5
  49. package/dist/src/home.js +6 -6
  50. package/dist/src/server/command.js +2 -2
  51. package/dist/src/server/index.d.ts +1 -1
  52. package/dist/src/server/index.js +2 -2
  53. package/dist/src/storage/sqlite/database.d.ts +5 -0
  54. package/dist/src/storage/sqlite/database.js +32 -1
  55. package/dist/src/storage/sqlite/index.js +1 -2
  56. package/dist/src/storage/sqlite/schema.d.ts +3 -4
  57. package/dist/src/storage/sqlite/schema.js +4 -4
  58. package/node_modules/@uniac/agentic-workspace/README.md +5 -5
  59. package/node_modules/@uniac/agentic-workspace/dist/examples/authority.d.ts +0 -1
  60. package/node_modules/@uniac/agentic-workspace/dist/examples/authority.js +3 -16
  61. package/node_modules/@uniac/agentic-workspace/dist/src/actors/index.d.ts +13 -13
  62. package/node_modules/@uniac/agentic-workspace/dist/src/actors/index.js +9 -25
  63. package/node_modules/@uniac/agentic-workspace/dist/src/contracts/common.d.ts +1 -9
  64. package/node_modules/@uniac/agentic-workspace/dist/src/contracts/common.js +2 -4
  65. package/node_modules/@uniac/agentic-workspace/dist/src/contracts/forms.d.ts +0 -13
  66. package/node_modules/@uniac/agentic-workspace/dist/src/contracts/forms.js +0 -3
  67. package/node_modules/@uniac/agentic-workspace/dist/src/contracts/messages.d.ts +0 -3
  68. package/node_modules/@uniac/agentic-workspace/dist/src/contracts/messages.js +3 -3
  69. package/node_modules/@uniac/agentic-workspace/dist/src/contracts/work.d.ts +2 -15
  70. package/node_modules/@uniac/agentic-workspace/dist/src/contracts/work.js +9 -14
  71. package/node_modules/@uniac/agentic-workspace/dist/src/mcp/index.js +1 -1
  72. package/node_modules/@uniac/agentic-workspace/dist/src/persistence/index.d.ts +1 -4
  73. package/node_modules/@uniac/agentic-workspace/dist/src/persistence/sqlite.js +2 -15
  74. package/node_modules/@uniac/agentic-workspace/dist/src/records.d.ts +0 -7
  75. package/node_modules/@uniac/agentic-workspace/dist/src/records.js +0 -14
  76. package/node_modules/@uniac/agentic-workspace/dist/src/work/asks.d.ts +20 -19
  77. package/node_modules/@uniac/agentic-workspace/dist/src/work/asks.js +39 -41
  78. package/node_modules/@uniac/agentic-workspace/dist/src/work/index.js +18 -24
  79. package/node_modules/@uniac/agentic-workspace/docs/contracts.md +23 -29
  80. package/node_modules/@uniac/agentic-workspace/docs/design.md +13 -13
  81. package/node_modules/@uniac/agentic-workspace/docs/hub-integration.md +25 -50
  82. package/node_modules/@uniac/agentic-workspace/package.json +1 -1
  83. package/package.json +3 -3
  84. package/skills/agentorg/SKILL.md +39 -38
  85. package/skills/agentorg/references/claude-code.md +3 -4
  86. package/vendor/uniac-agentic-workspace-0.0.2-8aebc44.tgz +0 -0
  87. package/vendor/workspace.json +6 -6
  88. package/dist/src/clients/mcp/levels.d.ts +0 -17
  89. package/dist/src/clients/mcp/levels.js +0 -7
  90. package/vendor/uniac-agentic-workspace-0.0.1-26fd0ee.tgz +0 -0
@@ -6,7 +6,6 @@ export declare const MESSAGES: {
6
6
  name: "messages";
7
7
  interfaces: {
8
8
  readonly message_send: {
9
- level: "organization" | "report" | "team";
10
9
  request: z.ZodObject<{
11
10
  recipientID: z.ZodString;
12
11
  text: z.ZodString;
@@ -32,7 +31,6 @@ export declare const MESSAGES: {
32
31
  writes: boolean;
33
32
  };
34
33
  readonly message_get: {
35
- level: "organization" | "report" | "team";
36
34
  request: z.ZodObject<{
37
35
  messageID: z.ZodString;
38
36
  }, z.core.$strict>;
@@ -57,7 +55,6 @@ export declare const MESSAGES: {
57
55
  writes: boolean;
58
56
  };
59
57
  readonly message_list: {
60
- level: "organization" | "report" | "team";
61
58
  request: z.ZodObject<{
62
59
  between: z.ZodOptional<z.ZodArray<z.ZodString>>;
63
60
  counterpartyID: z.ZodOptional<z.ZodString>;
@@ -97,7 +94,6 @@ export declare const WORK: {
97
94
  name: "work";
98
95
  interfaces: {
99
96
  readonly work_create: {
100
- level: "organization" | "report" | "team";
101
97
  request: z.ZodObject<{
102
98
  title: z.ZodString;
103
99
  goal: z.ZodOptional<z.ZodString>;
@@ -198,10 +194,6 @@ export declare const WORK: {
198
194
  note?: string | undefined;
199
195
  at: string;
200
196
  }>;
201
- raises: {
202
- actorID: string;
203
- at: string;
204
- }[];
205
197
  resolution?: {
206
198
  text: string;
207
199
  reason?: "cancelled" | "reassigned" | "submitted" | undefined;
@@ -292,10 +284,6 @@ export declare const WORK: {
292
284
  note?: string | undefined;
293
285
  at: string;
294
286
  }>;
295
- raises: {
296
- actorID: string;
297
- at: string;
298
- }[];
299
287
  resolution?: {
300
288
  text: string;
301
289
  reason?: "cancelled" | "reassigned" | "submitted" | undefined;
@@ -307,7 +295,6 @@ export declare const WORK: {
307
295
  writes: boolean;
308
296
  };
309
297
  readonly work_get: {
310
- level: "organization" | "report" | "team";
311
298
  request: z.ZodObject<{
312
299
  ticketID: z.ZodOptional<z.ZodString>;
313
300
  askID: z.ZodOptional<z.ZodString>;
@@ -425,10 +412,6 @@ export declare const WORK: {
425
412
  note?: string | undefined;
426
413
  at: string;
427
414
  }>;
428
- raises: {
429
- actorID: string;
430
- at: string;
431
- }[];
432
415
  resolution?: {
433
416
  text: string;
434
417
  reason?: "cancelled" | "reassigned" | "submitted" | undefined;
@@ -474,10 +457,6 @@ export declare const WORK: {
474
457
  note?: string | undefined;
475
458
  at: string;
476
459
  }>;
477
- raises: {
478
- actorID: string;
479
- at: string;
480
- }[];
481
460
  resolution?: {
482
461
  text: string;
483
462
  reason?: "cancelled" | "reassigned" | "submitted" | undefined;
@@ -567,10 +546,6 @@ export declare const WORK: {
567
546
  note?: string | undefined;
568
547
  at: string;
569
548
  }>;
570
- raises: {
571
- actorID: string;
572
- at: string;
573
- }[];
574
549
  resolution?: {
575
550
  text: string;
576
551
  reason?: "cancelled" | "reassigned" | "submitted" | undefined;
@@ -616,10 +591,6 @@ export declare const WORK: {
616
591
  note?: string | undefined;
617
592
  at: string;
618
593
  }>;
619
- raises: {
620
- actorID: string;
621
- at: string;
622
- }[];
623
594
  resolution?: {
624
595
  text: string;
625
596
  reason?: "cancelled" | "reassigned" | "submitted" | undefined;
@@ -630,13 +601,10 @@ export declare const WORK: {
630
601
  writes: boolean;
631
602
  };
632
603
  readonly work_list: {
633
- level: "organization" | "report" | "team";
634
604
  request: z.ZodObject<{
635
- ownerID: z.ZodOptional<z.ZodString>;
605
+ ownerID: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
636
606
  requesterID: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
637
607
  waitsOnActorID: z.ZodOptional<z.ZodString>;
638
- ownerWithin: z.ZodOptional<z.ZodString>;
639
- requesterWithin: z.ZodOptional<z.ZodString>;
640
608
  status: z.ZodOptional<z.ZodArray<z.ZodEnum<{
641
609
  accepted: "accepted";
642
610
  active: "active";
@@ -734,10 +702,6 @@ export declare const WORK: {
734
702
  note?: string | undefined;
735
703
  at: string;
736
704
  }>;
737
- raises: {
738
- actorID: string;
739
- at: string;
740
- }[];
741
705
  resolution?: {
742
706
  text: string;
743
707
  reason?: "cancelled" | "reassigned" | "submitted" | undefined;
@@ -828,10 +792,6 @@ export declare const WORK: {
828
792
  note?: string | undefined;
829
793
  at: string;
830
794
  }>;
831
- raises: {
832
- actorID: string;
833
- at: string;
834
- }[];
835
795
  resolution?: {
836
796
  text: string;
837
797
  reason?: "cancelled" | "reassigned" | "submitted" | undefined;
@@ -843,7 +803,6 @@ export declare const WORK: {
843
803
  writes: boolean;
844
804
  };
845
805
  readonly work_update: {
846
- level: "organization" | "report" | "team";
847
806
  request: z.ZodObject<{
848
807
  ticketID: z.ZodOptional<z.ZodString>;
849
808
  expectedRevision: z.ZodOptional<z.ZodNumber>;
@@ -980,10 +939,6 @@ export declare const WORK: {
980
939
  note?: string | undefined;
981
940
  at: string;
982
941
  }>;
983
- raises: {
984
- actorID: string;
985
- at: string;
986
- }[];
987
942
  resolution?: {
988
943
  text: string;
989
944
  reason?: "cancelled" | "reassigned" | "submitted" | undefined;
@@ -1029,10 +984,6 @@ export declare const WORK: {
1029
984
  note?: string | undefined;
1030
985
  at: string;
1031
986
  }>;
1032
- raises: {
1033
- actorID: string;
1034
- at: string;
1035
- }[];
1036
987
  resolution?: {
1037
988
  text: string;
1038
989
  reason?: "cancelled" | "reassigned" | "submitted" | undefined;
@@ -1122,10 +1073,6 @@ export declare const WORK: {
1122
1073
  note?: string | undefined;
1123
1074
  at: string;
1124
1075
  }>;
1125
- raises: {
1126
- actorID: string;
1127
- at: string;
1128
- }[];
1129
1076
  resolution?: {
1130
1077
  text: string;
1131
1078
  reason?: "cancelled" | "reassigned" | "submitted" | undefined;
@@ -1171,10 +1118,6 @@ export declare const WORK: {
1171
1118
  note?: string | undefined;
1172
1119
  at: string;
1173
1120
  }>;
1174
- raises: {
1175
- actorID: string;
1176
- at: string;
1177
- }[];
1178
1121
  resolution?: {
1179
1122
  text: string;
1180
1123
  reason?: "cancelled" | "reassigned" | "submitted" | undefined;
@@ -1185,7 +1128,6 @@ export declare const WORK: {
1185
1128
  writes: boolean;
1186
1129
  };
1187
1130
  readonly work_submit: {
1188
- level: "organization" | "report" | "team";
1189
1131
  request: z.ZodObject<{
1190
1132
  ticketID: z.ZodString;
1191
1133
  expectedRevision: z.ZodOptional<z.ZodNumber>;
@@ -1276,10 +1218,6 @@ export declare const WORK: {
1276
1218
  note?: string | undefined;
1277
1219
  at: string;
1278
1220
  }>;
1279
- raises: {
1280
- actorID: string;
1281
- at: string;
1282
- }[];
1283
1221
  resolution?: {
1284
1222
  text: string;
1285
1223
  reason?: "cancelled" | "reassigned" | "submitted" | undefined;
@@ -1370,10 +1308,6 @@ export declare const WORK: {
1370
1308
  note?: string | undefined;
1371
1309
  at: string;
1372
1310
  }>;
1373
- raises: {
1374
- actorID: string;
1375
- at: string;
1376
- }[];
1377
1311
  resolution?: {
1378
1312
  text: string;
1379
1313
  reason?: "cancelled" | "reassigned" | "submitted" | undefined;
@@ -1385,13 +1319,11 @@ export declare const WORK: {
1385
1319
  writes: boolean;
1386
1320
  };
1387
1321
  readonly work_answer: {
1388
- level: "organization" | "report" | "team";
1389
1322
  request: z.ZodObject<{
1390
1323
  askID: z.ZodString;
1391
1324
  ticketID: z.ZodOptional<z.ZodString>;
1392
- answers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
1325
+ answers: z.ZodRecord<z.ZodString, z.ZodString>;
1393
1326
  note: z.ZodOptional<z.ZodString>;
1394
- raise: z.ZodOptional<z.ZodLiteral<true>>;
1395
1327
  }, z.core.$strict>;
1396
1328
  response: z.ZodType<{
1397
1329
  revision: number;
@@ -1477,10 +1409,6 @@ export declare const WORK: {
1477
1409
  note?: string | undefined;
1478
1410
  at: string;
1479
1411
  }>;
1480
- raises: {
1481
- actorID: string;
1482
- at: string;
1483
- }[];
1484
1412
  resolution?: {
1485
1413
  text: string;
1486
1414
  reason?: "cancelled" | "reassigned" | "submitted" | undefined;
@@ -1526,10 +1454,6 @@ export declare const WORK: {
1526
1454
  note?: string | undefined;
1527
1455
  at: string;
1528
1456
  }>;
1529
- raises: {
1530
- actorID: string;
1531
- at: string;
1532
- }[];
1533
1457
  resolution?: {
1534
1458
  text: string;
1535
1459
  reason?: "cancelled" | "reassigned" | "submitted" | undefined;
@@ -1619,10 +1543,6 @@ export declare const WORK: {
1619
1543
  note?: string | undefined;
1620
1544
  at: string;
1621
1545
  }>;
1622
- raises: {
1623
- actorID: string;
1624
- at: string;
1625
- }[];
1626
1546
  resolution?: {
1627
1547
  text: string;
1628
1548
  reason?: "cancelled" | "reassigned" | "submitted" | undefined;
@@ -1668,10 +1588,6 @@ export declare const WORK: {
1668
1588
  note?: string | undefined;
1669
1589
  at: string;
1670
1590
  }>;
1671
- raises: {
1672
- actorID: string;
1673
- at: string;
1674
- }[];
1675
1591
  resolution?: {
1676
1592
  text: string;
1677
1593
  reason?: "cancelled" | "reassigned" | "submitted" | undefined;
@@ -3,7 +3,6 @@ import { MessageContracts, WorkContracts, } from "@uniac/agentic-workspace/contr
3
3
  import { toolDefinition } from "./json-schema.js";
4
4
  // Package descriptors retain input types; exported DTOs supply their response types.
5
5
  const spec = () => (definition) => ({
6
- level: definition.level,
7
6
  request: definition.input,
8
7
  response: definition.output,
9
8
  description: definition.description,
@@ -27,10 +27,9 @@ export interface Store {
27
27
  get(id: string): ActorRow | undefined;
28
28
  /** The open actor with this credential hash. */
29
29
  byCredentialHash(hash: string): ActorRow | undefined;
30
- root(): ActorRow | undefined;
31
- /** Open direct reports, oldest first. */
32
- reports(manager: string): ActorRow[];
33
- /** Every open actor, oldest first, so managers come before their reports. */
30
+ /** The first actor this store recorded. */
31
+ first(): ActorRow | undefined;
32
+ /** Every open actor, oldest first. */
34
33
  open(): ActorRow[];
35
34
  };
36
35
  claims: {
@@ -1,4 +1,4 @@
1
- /** Identity, actor tree and authorized lifecycle transitions, with credentials hashed by Web Crypto. */
1
+ /** Identity on one flat level and lifecycle transitions, with credentials hashed by Web Crypto. */
2
2
  import type { ActorRow, Store } from "./ports.ts";
3
3
  export type { ActorRow };
4
4
  export declare const newId: (prefix: string) => string;
@@ -7,7 +7,6 @@ export declare function registry(actors: Store["actors"], now: () => string): {
7
7
  id: string;
8
8
  name: string;
9
9
  purpose: string;
10
- manager: string | null;
11
10
  created_at: string;
12
11
  closed_at: string | null;
13
12
  credential_hash: string;
@@ -16,7 +15,7 @@ export declare function registry(actors: Store["actors"], now: () => string): {
16
15
  root: ActorRow;
17
16
  credential: string;
18
17
  }>;
19
- create: (manager: string, name: string, purpose: string) => Promise<{
18
+ create: (name: string, purpose: string) => Promise<{
20
19
  actor: ActorRow;
21
20
  credential: string;
22
21
  }>;
@@ -25,7 +24,6 @@ export declare function registry(actors: Store["actors"], now: () => string): {
25
24
  id: string;
26
25
  name: string;
27
26
  purpose: string;
28
- manager: string | null;
29
27
  created_at: string;
30
28
  closed_at: string | null;
31
29
  credential_hash: string;
@@ -33,31 +31,19 @@ export declare function registry(actors: Store["actors"], now: () => string): {
33
31
  found: (id: string) => ActorRow;
34
32
  byCredential: (credential: string) => Promise<ActorRow | undefined>;
35
33
  identify: (credential: string) => Promise<string | undefined>;
36
- reports: (manager: string) => {
37
- id: string;
38
- name: string;
39
- purpose: string;
40
- manager: string | null;
41
- created_at: string;
42
- closed_at: string | null;
43
- credential_hash: string;
44
- }[];
45
34
  open: () => {
46
35
  id: string;
47
36
  name: string;
48
37
  purpose: string;
49
- manager: string | null;
50
38
  created_at: string;
51
39
  closed_at: string | null;
52
40
  credential_hash: string;
53
41
  }[];
54
- within: (actorID: string, ancestorID: string) => boolean;
55
42
  standIn: (actorID: string) => string | undefined;
56
43
  close: (caller: ActorRow, id: string) => {
57
44
  actor: ActorRow;
58
45
  changed: boolean;
59
46
  };
60
- path: (actor: ActorRow) => string;
61
47
  names: (ids: Iterable<string>) => Record<string, string>;
62
48
  };
63
49
  export type Registry = ReturnType<typeof registry>;
@@ -1,4 +1,4 @@
1
- /** Identity, actor tree and authorized lifecycle transitions, with credentials hashed by Web Crypto. */
1
+ /** Identity on one flat level and lifecycle transitions, with credentials hashed by Web Crypto. */
2
2
  import { Conflict, Forbidden, Invalid, NotFound } from "./errors.js";
3
3
  const random = (length) => crypto.getRandomValues(new Uint8Array(length));
4
4
  const hex = (bytes) => Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0")).join("");
@@ -14,56 +14,41 @@ const mintCredential = () => btoa(String.fromCharCode(...random(32)))
14
14
  .replaceAll("/", "_")
15
15
  .replace(/=+$/, "");
16
16
  export function registry(actors, now) {
17
- const root = () => actors.root();
17
+ /** The person: the first Actor this Hub made, the one place that says so. */
18
+ const root = () => actors.first();
18
19
  const get = (id) => actors.get(id);
19
- const reports = (manager) => actors.reports(manager);
20
20
  const open = () => actors.open();
21
- /** The Actor while it is open, else its nearest open manager, who takes its part. */
21
+ /** The Actor while it is open; once it is closed, the person, who takes its part. */
22
22
  function standIn(actorID) {
23
- for (let at = get(actorID); at; at = at.manager === null ? undefined : get(at.manager))
24
- if (at.closed_at === null)
25
- return at.id;
26
- return undefined;
23
+ const actor = get(actorID);
24
+ return actor === undefined ? undefined : actor.closed_at === null ? actor.id : root()?.id;
27
25
  }
28
- /** Inclusive ancestry through retained positions, including closed Actors. */
29
- function within(actorID, ancestorID) {
30
- if (get(ancestorID) === undefined)
31
- return false;
32
- const visited = new Set();
33
- for (let at = get(actorID); at !== undefined && !visited.has(at.id); at = at.manager === null ? undefined : get(at.manager)) {
34
- if (at.id === ancestorID)
35
- return true;
36
- visited.add(at.id);
37
- }
38
- return false;
39
- }
40
- /** Create the root, the user's position, and return its credential. */
26
+ /** Create the person, the user's Actor, and return its credential. */
41
27
  async function createRoot() {
42
28
  const { credential, hash } = await mint();
43
29
  return {
44
- root: insert(null, "root", "The user, at the organization's root.", hash),
30
+ root: insert("root", "The user: the person these Actors work for.", hash),
45
31
  credential,
46
32
  };
47
33
  }
48
- /** Create a report of `manager` and return it with its credential. */
49
- async function create(manager, name, purpose) {
34
+ /** Create an Actor and return it with its credential. */
35
+ async function create(name, purpose) {
50
36
  // Hashing waits, so it comes first: the check and the insert then run with nothing between.
51
37
  const { credential, hash } = await mint();
52
- if (reports(manager).some((report) => report.name === name)) {
53
- throw new Conflict(`a report of ${manager} is already named ${name}`);
38
+ if (open().some((actor) => actor.name === name)) {
39
+ throw new Conflict(`an open Actor is already named ${name}`);
54
40
  }
55
- return { actor: insert(manager, name, purpose, hash), credential };
41
+ return { actor: insert(name, purpose, hash), credential };
56
42
  }
57
43
  async function mint() {
58
44
  const credential = mintCredential();
59
45
  return { credential, hash: await digest(credential) };
60
46
  }
61
- function insert(manager, name, purpose, hash) {
47
+ function insert(name, purpose, hash) {
62
48
  const actor = {
63
49
  id: newId("act"),
64
50
  name,
65
51
  purpose,
66
- manager,
67
52
  credential_hash: hash,
68
53
  created_at: now(),
69
54
  closed_at: null,
@@ -71,7 +56,7 @@ export function registry(actors, now) {
71
56
  actors.insert(actor);
72
57
  return actor;
73
58
  }
74
- /** Replace an actor's credential, as when the root's file is lost, and return the new one. */
59
+ /** Replace an actor's credential, as when the person's file is lost, and return the new one. */
75
60
  async function rotateCredential(id) {
76
61
  const { credential, hash } = await mint();
77
62
  actors.update({ ...found(id), credential_hash: hash });
@@ -91,40 +76,26 @@ export function registry(actors, now) {
91
76
  async function identify(credential) {
92
77
  return (await byCredential(credential))?.id;
93
78
  }
94
- /** Close an authorized leaf position; repeat closure leaves its timestamp unchanged. */
79
+ /** Close another Actor, never the person; repeat closure leaves its timestamp unchanged. */
95
80
  function close(caller, id) {
96
81
  const target = found(id);
97
- if (target.manager === null)
98
- throw new Invalid("the root is never closed");
99
- if (target.manager !== caller.id && caller.manager !== null) {
100
- throw new Forbidden(`only its manager or the root closes ${target.name}`);
101
- }
82
+ if (target.id === root()?.id)
83
+ throw new Invalid("the person is never closed");
84
+ if (target.id === caller.id)
85
+ throw new Forbidden("an Actor closes others, not itself");
102
86
  if (target.closed_at !== null)
103
87
  return { actor: target, changed: false };
104
- const children = reports(id);
105
- if (children.length > 0) {
106
- const names = children.map((report) => report.name).join(", ");
107
- throw new Conflict(`${target.name} has open reports (${names}); close them first`);
108
- }
109
88
  const actor = { ...target, closed_at: now() };
110
89
  actors.update(actor);
111
90
  return { actor, changed: true };
112
91
  }
113
- /** The handles from the root's report down to the actor, joined by dots; empty for the root. */
114
- function path(actor) {
115
- const handles = [];
116
- for (let at = actor; at?.manager; at = get(at.manager)) {
117
- handles.unshift(at.name);
118
- }
119
- return handles.join(".");
120
- }
121
- /** Each of these actors by id: its path, or for the root its name. */
92
+ /** Each of these actors by id: its handle. */
122
93
  function names(ids) {
123
94
  const named = {};
124
95
  for (const id of new Set(ids)) {
125
96
  const actor = get(id);
126
97
  if (actor)
127
- named[id] = path(actor) || actor.name;
98
+ named[id] = actor.name;
128
99
  }
129
100
  return named;
130
101
  }
@@ -137,12 +108,9 @@ export function registry(actors, now) {
137
108
  found,
138
109
  byCredential,
139
110
  identify,
140
- reports,
141
111
  open,
142
- within,
143
112
  standIn,
144
113
  close,
145
- path,
146
114
  names,
147
115
  };
148
116
  }
@@ -17,11 +17,7 @@ export function system(registry, connections, diagnostics, now, runtime) {
17
17
  if (entry.connectionId === how.connectionId)
18
18
  return "current_connection";
19
19
  const root = registry.root()?.id === actor.id;
20
- const allowed = "actorId" in entry.principal
21
- ? root ||
22
- entry.principal.actorId === actor.id ||
23
- registry.get(entry.principal.actorId)?.manager === actor.id
24
- : root;
20
+ const allowed = "actorId" in entry.principal ? root || entry.principal.actorId === actor.id : root;
25
21
  if (!allowed)
26
22
  return "forbidden";
27
23
  if (entry.state === "closing")
@@ -1,4 +1,4 @@
1
- /** Organization hierarchy, actual admitted connection presence and each Actor's report. */
1
+ /** Every open Actor, actual admitted connection presence and each Actor's report. */
2
2
  import type { Actors } from "./actors.ts";
3
3
  import type { Audit } from "./audit.ts";
4
4
  import type { Registry } from "./registry.ts";
@@ -1,4 +1,4 @@
1
- /** Organization hierarchy, actual admitted connection presence and each Actor's report. */
1
+ /** Every open Actor, actual admitted connection presence and each Actor's report. */
2
2
  import { WorkspaceError, } from "@uniac/agentic-workspace/contracts";
3
3
  import { TEAM } from "./model/index.js";
4
4
  import { bindTool } from "./tools.js";
@@ -92,7 +92,7 @@ export function team(registry, actors, audit, workspace) {
92
92
  if (state === "review")
93
93
  return {
94
94
  kind: "review",
95
- // A closed requester's part passes to its nearest open manager.
95
+ // A closed requester's part passes to the person.
96
96
  text: `with ${named(registry.standIn(item.requesterID) ?? item.requesterID)} for review`,
97
97
  };
98
98
  const on = item.waitsOn;
@@ -130,27 +130,17 @@ export function team(registry, actors, audit, workspace) {
130
130
  };
131
131
  }
132
132
  /**
133
- * The start and its open reports to `depth`, each with its state, headline and ask counts. Up to
134
- * `FEW` positions read their own Work, more read the organization's once, and open asks are one
135
- * pass.
133
+ * Every open Actor, oldest first, each with its state, headline and open asks. Up to `FEW`
134
+ * Actors read their own Work, more read the organization's once, and open asks are one pass.
136
135
  */
137
- function readTeam(caller, request) {
138
- const start = request.actor === undefined ? caller : registry.found(request.actor);
139
- const rows = [];
140
- const visit = (at, depth) => {
141
- rows.push(at);
142
- if (depth > 0)
143
- for (const report of registry.reports(at.id))
144
- visit(report, depth - 1);
145
- };
146
- visit(start, request.depth);
136
+ function readTeam(caller) {
137
+ const rows = registry.open();
147
138
  const few = rows.length <= FEW;
148
139
  const positions = workspace.run(caller, ({ work }) => {
149
140
  const list = (filter) => all((after) => work.list({ ...filter, limit: 100, after }));
150
141
  const live = few
151
142
  ? rows.flatMap((row) => list({ ownerID: row.id, status: [...UNFINISHED] }))
152
143
  : list({ status: [...UNFINISHED] });
153
- // Asks stay one pass: branchAsks counts the asks at every depth below each position.
154
144
  const open = oldestFirst(all((after) => work.asks({ status: ["open"], limit: 100, after })));
155
145
  const latest = (actorID) => work.list({ ownerID: actorID, status: ["accepted"], order: "recent", limit: 1 }).items[0];
156
146
  const recent = few
@@ -161,20 +151,14 @@ export function team(registry, actors, audit, workspace) {
161
151
  ? latest(actorID)
162
152
  : (recent.items.find((item) => item.ownerID === actorID) ??
163
153
  (recent.next === null ? undefined : latest(actorID)));
164
- /** Open asks below each Actor: each counts once for every manager above its asker. */
165
- const below = new Map();
166
- for (const ask of open)
167
- for (let at = registry.get(ask.requesterID); at?.manager; at = registry.get(at.manager))
168
- below.set(at.manager, (below.get(at.manager) ?? 0) + 1);
169
154
  return rows.map((row) => ({
170
155
  ...actors.view(row),
171
156
  ...standing(caller, work, live.filter((item) => item.ownerID === row.id), live, finished(row.id)),
172
157
  asks: open.filter((ask) => ask.requesterID === row.id).length,
173
- branchAsks: below.get(row.id) ?? 0,
174
158
  lastActiveAt: audit.lastWrite(row.id) ?? null,
175
159
  }));
176
160
  });
177
- return { root: registry.root().id, positions };
161
+ return { positions };
178
162
  }
179
163
  /**
180
164
  * An Actor's report: its state and headline as `team` gives them, from the same Work, the Work
@@ -185,7 +169,6 @@ export function team(registry, actors, audit, workspace) {
185
169
  function view(caller, request) {
186
170
  const viewed = request.actorID === undefined ? caller : registry.found(request.actorID);
187
171
  const id = viewed.id;
188
- const reports = registry.reports(id);
189
172
  return workspace.run(caller, ({ work }) => {
190
173
  const names = {};
191
174
  const named = (page) => {
@@ -197,23 +180,21 @@ export function team(registry, actors, audit, workspace) {
197
180
  const mine = works({ ownerID: id, status: [...UNFINISHED] });
198
181
  const last = work.list({ ownerID: id, status: ["accepted"], order: "recent", limit: 1 })
199
182
  .items[0];
200
- // Work routed to it as requester: its own, and a closed requester's it stands in for.
201
- const requested = oldestFirst(all((after) => work.list({ requesterWithin: id, status: [...UNFINISHED], limit: 100, after }))).filter((item) => registry.standIn(item.requesterID) === id);
183
+ // Work routed to it as requester: its own, and for the person a closed requester's too.
184
+ const requesterID = registry.root()?.id === id ? {} : { requesterID: id };
185
+ const requested = oldestFirst(all((after) => work.list({ ...requesterID, status: [...UNFINISHED], limit: 100, after }))).filter((item) => registry.standIn(item.requesterID) === id);
202
186
  const reviews = requested.filter((item) => item.status === "submitted");
203
187
  const ownerClosed = requested.filter((item) => item.status !== "submitted" && registry.found(item.ownerID).closed_at !== null);
204
- for (const actor of [viewed, ...reports])
205
- names[actor.id] = { name: actor.name };
188
+ names[id] = { name: viewed.name };
206
189
  for (const item of [...reviews, ...ownerClosed])
207
190
  for (const party of [item.ownerID, item.requesterID])
208
191
  names[party] = { name: registry.found(party).name };
209
- const { path, online } = actors.view(viewed);
192
+ const { online } = actors.view(viewed);
210
193
  return {
211
194
  actor: {
212
195
  actorID: id,
213
196
  name: viewed.name,
214
- path,
215
197
  purpose: viewed.purpose,
216
- managerID: viewed.manager,
217
198
  online,
218
199
  lastActiveAt: audit.lastWrite(id) ?? null,
219
200
  closed_at: viewed.closed_at,
@@ -240,14 +221,13 @@ export function team(registry, actors, audit, workspace) {
240
221
  order: "recent",
241
222
  limit: request.completed,
242
223
  })).items,
243
- reports: reports.map(actors.view),
244
224
  actors: names,
245
225
  };
246
226
  });
247
227
  }
248
228
  return {
249
229
  tool: bindTool(TEAM, {
250
- team: (actor, request) => readTeam(actor, request),
230
+ team: (actor) => readTeam(actor),
251
231
  actor_view: (actor, request) => view(actor, request),
252
232
  }),
253
233
  };
@@ -18,16 +18,8 @@ export function workspace(registry, store) {
18
18
  const actor = registry.get(actorID);
19
19
  return actor === undefined ? undefined : profile(actor);
20
20
  },
21
- within(callerID, actorID, ancestorID) {
22
- if (registry.get(callerID)?.closed_at !== null)
23
- throw new Forbidden("the Actor is closed");
24
- return registry.within(actorID, ancestorID);
25
- },
26
- manager(callerID, actorID) {
27
- if (registry.get(callerID)?.closed_at !== null)
28
- throw new Forbidden("the Actor is closed");
29
- return registry.get(actorID)?.manager ?? null;
30
- },
21
+ // Called only for a revalidated active caller; the person is never closed.
22
+ person: () => registry.root().id,
31
23
  };
32
24
  /** Run an operation on the package clients bound to the admitted Actor, mapping its refusals. */
33
25
  function run(actor, operation) {