melchizedek-agents 1.1.0 → 1.2.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 (118) hide show
  1. package/.env.example +10 -0
  2. package/AGENT_SETUP.md +3 -1
  3. package/CHANGELOG.md +232 -0
  4. package/DOCUMENTATION.md +91 -16
  5. package/ONBOARDING.md +339 -0
  6. package/QUICKSTART.md +15 -2
  7. package/README.md +5 -2
  8. package/config/agents/examples/council.yaml +1 -1
  9. package/config/agents/examples/critic.yaml +8 -8
  10. package/config/agents/examples/image_production.yaml +4 -3
  11. package/config/agents/syndicate.schema.json +65 -7
  12. package/config/agents/syndicateSchema.yaml +18 -6
  13. package/config/agents/templates/intake_extractor.yaml +3 -2
  14. package/config/agents/templates/systems_operator.yaml +5 -2
  15. package/dist/lib/a2a/app.d.ts +12 -0
  16. package/dist/lib/a2a/app.js +22 -11
  17. package/dist/lib/a2a/executor.js +14 -6
  18. package/dist/lib/a2a/oauthSetup.d.ts +16 -0
  19. package/dist/lib/a2a/oauthSetup.js +57 -3
  20. package/dist/lib/agentDialect.d.ts +18 -8
  21. package/dist/lib/agentDialect.js +36 -19
  22. package/dist/lib/compile.d.ts +38 -7
  23. package/dist/lib/compile.js +57 -37
  24. package/dist/lib/compileNative.d.ts +11 -3
  25. package/dist/lib/compileNative.js +18 -1
  26. package/dist/lib/doctor.d.ts +76 -0
  27. package/dist/lib/doctor.js +159 -7
  28. package/dist/lib/loadSyndicate.d.ts +9 -0
  29. package/dist/lib/models/capabilities.d.ts +9 -0
  30. package/dist/lib/models/capabilities.js +24 -0
  31. package/dist/lib/models/chatCompletionsAdapter.d.ts +11 -3
  32. package/dist/lib/models/chatCompletionsAdapter.js +19 -5
  33. package/dist/lib/models/claudeAdapter.js +4 -0
  34. package/dist/lib/models/contract.d.ts +5 -2
  35. package/dist/lib/models/gateway.d.ts +2 -1
  36. package/dist/lib/models/gateway.js +4 -2
  37. package/dist/lib/models/gatewayAdapter.d.ts +7 -1
  38. package/dist/lib/models/gatewayAdapter.js +8 -0
  39. package/dist/lib/models/geminiAdapter.js +8 -2
  40. package/dist/lib/models/genaiMapping.d.ts +8 -4
  41. package/dist/lib/models/genaiMapping.js +23 -9
  42. package/dist/lib/models/gptAdapter.d.ts +4 -2
  43. package/dist/lib/models/gptAdapter.js +11 -4
  44. package/dist/lib/models/grokAdapter.d.ts +3 -1
  45. package/dist/lib/models/grokAdapter.js +11 -3
  46. package/dist/lib/models/kimiAdapter.d.ts +2 -1
  47. package/dist/lib/models/kimiAdapter.js +3 -3
  48. package/dist/lib/models/reasoning.d.ts +30 -2
  49. package/dist/lib/models/reasoning.js +56 -5
  50. package/dist/lib/onboarding.d.ts +134 -0
  51. package/dist/lib/onboarding.js +539 -0
  52. package/dist/lib/runtime/approvals.d.ts +2 -0
  53. package/dist/lib/runtime/approvals.js +4 -3
  54. package/dist/lib/runtime/credentials.d.ts +6 -0
  55. package/dist/lib/runtime/native/agentLoop.d.ts +5 -2
  56. package/dist/lib/runtime/native/agentLoop.js +2 -0
  57. package/dist/lib/runtime/native/checkpoint.d.ts +12 -5
  58. package/dist/lib/runtime/native/checkpoint.js +13 -19
  59. package/dist/lib/runtime/native/delegate.d.ts +82 -1
  60. package/dist/lib/runtime/native/delegate.js +157 -2
  61. package/dist/lib/runtime/native/interrupts.d.ts +88 -5
  62. package/dist/lib/runtime/native/interrupts.js +220 -30
  63. package/dist/lib/runtime/syndicateTurn.d.ts +4 -2
  64. package/dist/lib/runtime/syndicateTurn.js +295 -62
  65. package/dist/lib/runtime/turnControl.d.ts +41 -0
  66. package/dist/lib/session/transcript.d.ts +9 -0
  67. package/dist/lib/session/transcript.js +20 -1
  68. package/dist/lib/skills.d.ts +18 -0
  69. package/dist/lib/skills.js +73 -1
  70. package/dist/lib/storage/postgres/index.d.ts +6 -1
  71. package/dist/lib/storage/postgres/index.js +1 -1
  72. package/dist/lib/storage/postgres/taskQueue.d.ts +7 -3
  73. package/dist/lib/storage/postgres/taskQueue.js +10 -3
  74. package/dist/lib/syndicateSchema.d.ts +38 -1
  75. package/dist/lib/syndicateSchema.js +25 -18
  76. package/dist/lib/tools/auth.d.ts +13 -1
  77. package/dist/lib/tools/auth.js +10 -2
  78. package/dist/lib/tools/credentialHosts.d.ts +88 -0
  79. package/dist/lib/tools/credentialHosts.js +165 -0
  80. package/dist/lib/tools/credentialUses.d.ts +92 -0
  81. package/dist/lib/tools/credentialUses.js +112 -0
  82. package/dist/lib/tools/mcpToolFactory.js +1 -1
  83. package/dist/lib/tools/oauthConsent.js +8 -1
  84. package/dist/lib/tools/oauthHosts.d.ts +2 -0
  85. package/dist/lib/tools/oauthHosts.js +2 -2
  86. package/dist/lib/tools/oauthTools.d.ts +10 -1
  87. package/dist/lib/tools/oauthTools.js +29 -3
  88. package/dist/lib/tools/openapiTools.d.ts +7 -0
  89. package/dist/lib/tools/openapiTools.js +49 -3
  90. package/dist/lib/tools/taskTools.d.ts +32 -2
  91. package/dist/lib/tools/taskTools.js +93 -33
  92. package/dist/lib/workflow/turn.d.ts +22 -3
  93. package/dist/lib/workflow/turn.js +151 -31
  94. package/dist/lib/workflow.d.ts +10 -7
  95. package/dist/lib/workflow.js +10 -7
  96. package/dist/scripts/a2a_server.d.ts +2 -2
  97. package/dist/scripts/a2a_server.js +11 -2
  98. package/dist/scripts/assistant_worker.d.ts +2 -0
  99. package/dist/scripts/assistant_worker.js +13 -4
  100. package/dist/scripts/doctor.d.ts +4 -2
  101. package/dist/scripts/doctor.js +6 -4
  102. package/dist/scripts/setup.d.ts +23 -0
  103. package/dist/scripts/setup.js +154 -0
  104. package/dist/scripts/skills_install.d.ts +3 -1
  105. package/dist/scripts/skills_install.js +17 -2
  106. package/dist/scripts/yaml_codemod.d.ts +12 -2
  107. package/dist/scripts/yaml_codemod.js +115 -33
  108. package/package.json +4 -1
  109. package/skills/README.md +11 -2
  110. package/skills/briefs/_shared.md +1 -1
  111. package/skills/briefs/melchizedek-models.md +4 -2
  112. package/skills/briefs/skills-readme.md +3 -1
  113. package/skills/melchizedek-models/SKILL.md +6 -2
  114. package/skills/melchizedek-onboard/SKILL.md +49 -0
  115. package/skills/melchizedek-onboard-cloud/SKILL.md +38 -0
  116. package/skills/melchizedek-onboard-keys/SKILL.md +35 -0
  117. package/skills/melchizedek-onboard-local/SKILL.md +41 -0
  118. package/skills/melchizedek-onboard-serve/SKILL.md +43 -0
@@ -0,0 +1,134 @@
1
+ /**
2
+ * lib/onboarding.ts — the authentication levels and their startup guides.
3
+ *
4
+ * WHY this file exists:
5
+ * A newcomer arrives with something: no key, one provider's key, several, a
6
+ * gateway key, a cloud account, a server to put in front of other people,
7
+ * or a ChatGPT / Claude.ai / Gemini CLI sign-in. Each of those is a
8
+ * different first ten minutes. This module names those levels once, from
9
+ * what the engine actually supports (lib/models/providerMap.ts,
10
+ * endpoints.ts, gateway.ts, the A2A server's identity modes and the OAuth
11
+ * grant setup), and renders one startup guide per level. The
12
+ * `melchizedek-setup` menu prints these guides and ONBOARDING.md is
13
+ * generated from the same function, so the two cannot drift
14
+ * (tests/onboarding.test.ts holds them equal).
15
+ *
16
+ * DETECTION IS THE DOCTOR'S:
17
+ * `detectLevels` reads a DoctorResult (lib/doctor.ts: the providers line,
18
+ * the gateway, the cloud endpoints, the serving and OAuth lines). It never
19
+ * reads a key itself, so `--auto` cannot disagree with the doctor.
20
+ *
21
+ * WHAT IT NEVER DOES:
22
+ * print a value. Guides carry variable NAMES and SHAPES; detection carries
23
+ * names and set/unset. Writing `.env` (writeEnvForLevel) copies
24
+ * `.env.example`, leaves every chosen name blank, refuses to overwrite an
25
+ * existing file, and refuses unless `git check-ignore` says `.env` is
26
+ * ignored (secrets-hygiene).
27
+ */
28
+ import type { DoctorResult, Tier } from './doctor.ts';
29
+ export type LevelId = 'local' | 'one-provider' | 'several-providers' | 'gateway' | 'cloud-platform' | 'byok' | 'caller-tokens' | 'oauth-grants' | 'subscription-signin';
30
+ /** How a command is spelled: in a project that installed the package, or in a clone of the repository. */
31
+ export type CommandForm = 'package' | 'clone';
32
+ export interface EnvLine {
33
+ name: string;
34
+ /** The shape of the value, never a value. */
35
+ shape: string;
36
+ /** What setting it does. */
37
+ purpose: string;
38
+ }
39
+ export interface Level {
40
+ id: LevelId;
41
+ /** The menu line: what the user has. */
42
+ menu: string;
43
+ title: string;
44
+ summary: string;
45
+ env: EnvLine[];
46
+ /** What the doctor shows when this level is set up. */
47
+ confirm: string;
48
+ /** Shipped syndicates that run at this level, rendered by `shippedFor`. */
49
+ runs: (shipped: ShippedIndex) => string[];
50
+ first: Record<CommandForm, string[]>;
51
+ notes: string[];
52
+ /** The onboarding skill a coding agent follows for this level. */
53
+ skill: string;
54
+ /** False for an entry that is not a way to run the engine (subscription sign-ins). */
55
+ detectable: boolean;
56
+ }
57
+ /** Shipped templates and examples by the tier their models imply, and which declare an OAuth grant. */
58
+ export interface ShippedIndex {
59
+ byTier: Partial<Record<Tier, string[]>>;
60
+ withGrants: string[];
61
+ /** Files that carry a commented-out `oauth2:` grant to start from. */
62
+ grantExamples: string[];
63
+ templates: string[];
64
+ }
65
+ /** The package (or clone) root: the directory holding config/agents/syndicate.schema.json. */
66
+ export declare function packageRoot(from?: string): string;
67
+ /**
68
+ * Index the shipped templates and examples by tier, using the doctor's own
69
+ * diagnosis (lib/doctor.ts `diagnoseSyndicate`: the tier the models imply,
70
+ * and the OAuth grants the tools declare). The tier does not depend on the
71
+ * environment, so the index is the same wherever it is computed.
72
+ */
73
+ export declare function shippedIndex(root?: string): ShippedIndex;
74
+ export declare const LEVELS: readonly Level[];
75
+ export declare function levelById(id: string): Level | undefined;
76
+ /** Every variable name the guides mention. */
77
+ export declare function guideEnvNames(): string[];
78
+ /** One level's startup guide, as Markdown (the terminal prints the same text). */
79
+ export declare function renderGuide(level: Level, form: CommandForm, shipped?: ShippedIndex): string;
80
+ /** The menu: one numbered line per level. */
81
+ export declare function renderMenu(): string;
82
+ /** ONBOARDING.md, generated in full from the levels (package spelling). */
83
+ export declare function renderOnboardingDoc(shipped?: ShippedIndex): string;
84
+ export interface LevelDetection {
85
+ id: LevelId;
86
+ detected: boolean;
87
+ /** Names and set/unset only. */
88
+ evidence: string;
89
+ /** The doctor's problems for this level, by variable name. */
90
+ problems: string[];
91
+ }
92
+ /**
93
+ * Which levels the environment is set up for, read from the doctor's result.
94
+ * Local is always available (whether Ollama is running is not checked).
95
+ */
96
+ export declare function detectLevels(result: DoctorResult): LevelDetection[];
97
+ /** The highest detected level (the last in menu order). */
98
+ export declare function highestLevel(detections: LevelDetection[]): Level;
99
+ /** `--auto`: what the environment has (names only), then the guide for the highest level. */
100
+ export declare function renderAuto(result: DoctorResult, form: CommandForm, shipped?: ShippedIndex): string;
101
+ export type EnvWriteResult = {
102
+ status: 'written';
103
+ path: string;
104
+ added: string[];
105
+ } | {
106
+ status: 'exists';
107
+ path: string;
108
+ } | {
109
+ status: 'not-ignored';
110
+ path: string;
111
+ reason: string;
112
+ } | {
113
+ status: 'no-template';
114
+ path: string;
115
+ };
116
+ /** True when git confirms `.env` in `cwd` is ignored (exit 0 from `git check-ignore`). */
117
+ export declare function gitIgnoresEnv(cwd: string): {
118
+ ignored: boolean;
119
+ reason: string;
120
+ };
121
+ /**
122
+ * Create `.env` from `.env.example` for a level: the template verbatim, then
123
+ * every name the level lists that the template does not already assign, left
124
+ * blank. Never overwrites, never writes a value, and refuses unless git
125
+ * confirms `.env` is ignored. The file is created mode 600.
126
+ */
127
+ export declare function writeEnvForLevel(level: Level, opts?: {
128
+ cwd?: string;
129
+ root?: string;
130
+ checkIgnored?: (cwd: string) => {
131
+ ignored: boolean;
132
+ reason: string;
133
+ };
134
+ }): EnvWriteResult;