@sigrun/sigrun 0.2.1 → 0.3.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.
Files changed (51) hide show
  1. package/CHANGELOG.md +50 -0
  2. package/README.md +234 -1
  3. package/dist/cli.js +117 -19
  4. package/dist/config.js +21 -2
  5. package/dist/extension.d.ts +7 -1
  6. package/dist/harness/ambient.js +2 -0
  7. package/dist/harness/blocks/state.js +1 -0
  8. package/dist/harness/boot.js +86 -6
  9. package/dist/harness/context.js +25 -0
  10. package/dist/harness/event-bus.js +25 -14
  11. package/dist/harness/identity/accounts.js +3 -2
  12. package/dist/harness/identity/index.js +2 -1
  13. package/dist/harness/identity/invites.js +26 -9
  14. package/dist/harness/identity/link-sweep.js +47 -0
  15. package/dist/harness/identity/typed-username.js +15 -0
  16. package/dist/harness/identity/users.js +10 -7
  17. package/dist/harness/interactions.js +2 -0
  18. package/dist/harness/loader.js +57 -1
  19. package/dist/harness/migration-snapshot.js +97 -0
  20. package/dist/harness/reports.js +100 -0
  21. package/dist/harness/seam-host.js +11 -1
  22. package/dist/harness/settings.js +52 -4
  23. package/dist/jobs/docs.js +3 -0
  24. package/dist/jobs/fire.js +2 -0
  25. package/dist/jobs/parked.js +38 -0
  26. package/dist/jobs/task.js +37 -8
  27. package/dist/serve.js +23 -14
  28. package/dist/server/auth/ip.js +9 -4
  29. package/dist/server/auth/own-host.js +115 -0
  30. package/dist/server/auth/pipeline.js +64 -48
  31. package/dist/server/auth/proxy-diagnostic.js +60 -0
  32. package/dist/server/auth/proxy-identity.js +134 -0
  33. package/dist/server/auth/proxy-only.js +28 -0
  34. package/dist/server/login/resolve.js +88 -26
  35. package/dist/server/routes/admin.js +97 -0
  36. package/dist/server/routes/login.js +8 -0
  37. package/dist/server/routes/metrics.js +18 -2
  38. package/dist/server/routes/onboarding.js +97 -37
  39. package/dist/server/session-meta.js +1 -0
  40. package/dist/server/shutdown.js +93 -16
  41. package/dist/settings/registry.js +6 -0
  42. package/node_modules/@sigrun/shared/CHANGELOG.md +7 -0
  43. package/node_modules/@sigrun/shared/dist/settings.d.ts +14 -0
  44. package/node_modules/@sigrun/shared/dist/usernames.d.ts +8 -0
  45. package/node_modules/@sigrun/shared/dist/usernames.js +39 -0
  46. package/node_modules/@sigrun/shared/dist/views.d.ts +6 -4
  47. package/node_modules/@sigrun/shared/package.json +5 -1
  48. package/package.json +14 -12
  49. package/webui/dist/assets/{index-SO2W4jjk.js → index-CEOzj1C4.js} +11 -11
  50. package/webui/dist/index.html +1 -1
  51. package/dist/server/login/usernames.js +0 -15
@@ -0,0 +1,39 @@
1
+ export const MAX_USERNAME_LENGTH = 128;
2
+ export const MAX_SUFFIX_ATTEMPTS = 10_000;
3
+ const COMBINING_MARKS = /\p{M}/gu;
4
+ const AT_SIGNS = /@/g;
5
+ const INVALID_CHARACTERS = /[^a-z0-9._-]/g;
6
+ const LEADING_NON_ALPHANUMERIC = /^[^a-z0-9]+/;
7
+ const USERNAME_KEY = /^[a-z0-9][a-z0-9._-]*$/;
8
+ export class UsernameExhaustedError extends Error {
9
+ }
10
+ export function deriveUsername(input) {
11
+ const derived = input
12
+ .normalize("NFKD")
13
+ .replace(COMBINING_MARKS, "")
14
+ .toLowerCase()
15
+ .replace(AT_SIGNS, "_")
16
+ .replace(INVALID_CHARACTERS, "-")
17
+ .replace(LEADING_NON_ALPHANUMERIC, "")
18
+ .slice(0, MAX_USERNAME_LENGTH);
19
+ return derived === "" ? undefined : derived;
20
+ }
21
+ export function isUsernameKey(s) {
22
+ return s.length <= MAX_USERNAME_LENGTH && USERNAME_KEY.test(s);
23
+ }
24
+ export function foldSubject(s) {
25
+ return s.normalize("NFC").toLowerCase();
26
+ }
27
+ export function withSuffix(base, taken) {
28
+ if (!taken(base)) {
29
+ return base;
30
+ }
31
+ for (let suffix = 2; suffix <= MAX_SUFFIX_ATTEMPTS; suffix += 1) {
32
+ const suffixText = `-${suffix}`;
33
+ const candidate = `${base.slice(0, MAX_USERNAME_LENGTH - suffixText.length)}${suffixText}`;
34
+ if (!taken(candidate)) {
35
+ return candidate;
36
+ }
37
+ }
38
+ throw new UsernameExhaustedError(`No available username for "${base}"`);
39
+ }
@@ -838,7 +838,9 @@ export interface OnboardingState {
838
838
  readonly methods: readonly ("token" | "proxy")[];
839
839
  readonly codeRequired: boolean;
840
840
  readonly proxyIdentity?: {
841
+ /** The would-be directory key; `subject` is the raw proxy header. */
841
842
  readonly user: string;
843
+ readonly subject: string;
842
844
  readonly name?: string;
843
845
  readonly email?: string;
844
846
  };
@@ -907,9 +909,9 @@ export interface TokenCreateResponse {
907
909
  }
908
910
  /**
909
911
  * One external identity linked to a directory user (multi-user §11.3):
910
- * the `accounts.json` record verbatim. `provider` is `chat:<channel>` or
911
- * `login:<slug>:<id>`; `subject` is the provider's stable subject
912
- * (numeric id, `+E.164`, email-shaped — opaque to sigrun).
912
+ * the `accounts.json` record verbatim. `provider` is `proxy`,
913
+ * `chat:<channel>`, or `login:<slug>:<id>`; `subject` is the provider's
914
+ * stable subject (numeric id, `+E.164`, email-shaped — opaque to sigrun).
913
915
  *
914
916
  * Served to extensions as `host.accounts` and to users as
915
917
  * `GET /v1/auth/accounts`.
@@ -919,7 +921,7 @@ export interface AccountLinkWire {
919
921
  readonly subject: string;
920
922
  readonly user: string;
921
923
  readonly linkedAt: number;
922
- readonly via: "login" | "self" | "pairing" | "admin";
924
+ readonly via: "login" | "self" | "pairing" | "admin" | "proxy";
923
925
  }
924
926
  /**
925
927
  * The `GET /v1/auth/accounts` payload (multi-user §11.3): the caller's
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sigrun/shared",
3
- "version": "0.2.1",
3
+ "version": "0.3.0",
4
4
  "description": "sigrun shared leaf package \u2014 theme tokens, turn/conversation shaping, and the channel wire types (pure leaf, zero dependencies)",
5
5
  "type": "module",
6
6
  "exports": {
@@ -8,6 +8,10 @@
8
8
  "types": "./dist/themes.d.ts",
9
9
  "default": "./dist/themes.js"
10
10
  },
11
+ "./usernames": {
12
+ "types": "./dist/usernames.d.ts",
13
+ "default": "./dist/usernames.js"
14
+ },
11
15
  "./conversations": {
12
16
  "types": "./dist/conversations.d.ts",
13
17
  "default": "./dist/conversations.js"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sigrun/sigrun",
3
- "version": "0.2.1",
3
+ "version": "0.3.0",
4
4
  "description": "Durable personal assistant on pi-durable",
5
5
  "type": "module",
6
6
  "exports": {
@@ -39,19 +39,20 @@
39
39
  },
40
40
  "dependencies": {
41
41
  "@aws-sdk/client-s3": "^3.1154.0",
42
- "@earendil-works/chord": "1.3.0",
43
- "@earendil-works/pi-ai": "1.3.0",
44
- "@earendil-works/pi-durable": "1.3.0",
42
+ "@earendil-works/chord": "1.4.0",
43
+ "@earendil-works/pi-ai": "1.4.0",
44
+ "@earendil-works/pi-durable": "1.4.0",
45
45
  "@earendil-works/pi-tui": "^1.3.0",
46
46
  "@fastify/static": "^10.1.7",
47
- "@sigrun/ext-codemode": "0.1.1",
48
- "@sigrun/ext-gateway": "0.1.2",
49
- "@sigrun/ext-mcp": "0.2.1",
50
- "@sigrun/ext-tool-search": "0.1.1",
47
+ "@sigrun/ext-codemode": "0.1.2",
48
+ "@sigrun/ext-gateway": "0.1.4",
49
+ "@sigrun/ext-mcp": "0.2.2",
50
+ "@sigrun/ext-tool-search": "0.1.2",
51
51
  "@sigrun/oauth": "0.1.1",
52
- "@sigrun/shared": "0.2.1",
52
+ "@sigrun/shared": "0.3.0",
53
53
  "croner": "^10.0.1",
54
54
  "fastify": "^5.12.7",
55
+ "semver": "^7.8.5",
55
56
  "sharp": "^0.35.5",
56
57
  "typebox": "1.3.27"
57
58
  },
@@ -59,12 +60,13 @@
59
60
  "@sigrun/shared"
60
61
  ],
61
62
  "optionalDependencies": {
62
- "@sigrun/sandbox-linux-arm64": "0.2.1",
63
- "@sigrun/sandbox-linux-x64": "0.2.1",
64
- "@sigrun/tui": "0.2.1"
63
+ "@sigrun/sandbox-linux-arm64": "0.3.0",
64
+ "@sigrun/sandbox-linux-x64": "0.3.0",
65
+ "@sigrun/tui": "0.3.0"
65
66
  },
66
67
  "devDependencies": {
67
68
  "@types/node": "^26.6.4",
69
+ "@types/semver": "^7.8.0",
68
70
  "fast-check": "^4.10.2",
69
71
  "tsx": "^4.23.15",
70
72
  "typescript": "^7.0.2",