@tagma/sdk 0.7.1 → 0.7.4

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 (108) hide show
  1. package/README.md +109 -48
  2. package/dist/adapters/stdin-approval.d.ts +1 -5
  3. package/dist/adapters/stdin-approval.d.ts.map +1 -1
  4. package/dist/adapters/stdin-approval.js +1 -89
  5. package/dist/adapters/stdin-approval.js.map +1 -1
  6. package/dist/adapters/websocket-approval.d.ts +1 -27
  7. package/dist/adapters/websocket-approval.d.ts.map +1 -1
  8. package/dist/adapters/websocket-approval.js +1 -146
  9. package/dist/adapters/websocket-approval.js.map +1 -1
  10. package/dist/approval.d.ts +2 -12
  11. package/dist/approval.d.ts.map +1 -1
  12. package/dist/approval.js +1 -90
  13. package/dist/approval.js.map +1 -1
  14. package/dist/bootstrap.d.ts +21 -1
  15. package/dist/bootstrap.d.ts.map +1 -1
  16. package/dist/bootstrap.js +21 -11
  17. package/dist/bootstrap.js.map +1 -1
  18. package/dist/core/run-context.d.ts +3 -0
  19. package/dist/core/run-context.d.ts.map +1 -1
  20. package/dist/core/run-context.js +2 -0
  21. package/dist/core/run-context.js.map +1 -1
  22. package/dist/core/task-executor.d.ts.map +1 -1
  23. package/dist/core/task-executor.js +24 -37
  24. package/dist/core/task-executor.js.map +1 -1
  25. package/dist/engine.d.ts +8 -53
  26. package/dist/engine.d.ts.map +1 -1
  27. package/dist/engine.js +7 -294
  28. package/dist/engine.js.map +1 -1
  29. package/dist/index.d.ts +5 -5
  30. package/dist/index.d.ts.map +1 -1
  31. package/dist/index.js +2 -3
  32. package/dist/index.js.map +1 -1
  33. package/dist/logger.d.ts +2 -60
  34. package/dist/logger.d.ts.map +1 -1
  35. package/dist/logger.js +1 -153
  36. package/dist/logger.js.map +1 -1
  37. package/dist/plugins.d.ts +3 -3
  38. package/dist/plugins.d.ts.map +1 -1
  39. package/dist/plugins.js +1 -1
  40. package/dist/plugins.js.map +1 -1
  41. package/dist/registry.d.ts +2 -60
  42. package/dist/registry.d.ts.map +1 -1
  43. package/dist/registry.js +1 -253
  44. package/dist/registry.js.map +1 -1
  45. package/dist/runner.d.ts +1 -35
  46. package/dist/runner.d.ts.map +1 -1
  47. package/dist/runner.js +1 -610
  48. package/dist/runner.js.map +1 -1
  49. package/dist/runtime/adapters/stdin-approval.d.ts +2 -0
  50. package/dist/runtime/adapters/stdin-approval.d.ts.map +1 -0
  51. package/dist/runtime/adapters/stdin-approval.js +2 -0
  52. package/dist/runtime/adapters/stdin-approval.js.map +1 -0
  53. package/dist/runtime/adapters/websocket-approval.d.ts +2 -0
  54. package/dist/runtime/adapters/websocket-approval.d.ts.map +1 -0
  55. package/dist/runtime/adapters/websocket-approval.js +2 -0
  56. package/dist/runtime/adapters/websocket-approval.js.map +1 -0
  57. package/dist/runtime/bun-process-runner.d.ts +2 -0
  58. package/dist/runtime/bun-process-runner.d.ts.map +1 -0
  59. package/dist/runtime/bun-process-runner.js +2 -0
  60. package/dist/runtime/bun-process-runner.js.map +1 -0
  61. package/dist/runtime.d.ts +3 -0
  62. package/dist/runtime.d.ts.map +1 -0
  63. package/dist/runtime.js +2 -0
  64. package/dist/runtime.js.map +1 -0
  65. package/dist/schema.d.ts.map +1 -1
  66. package/dist/schema.js +1 -7
  67. package/dist/schema.js.map +1 -1
  68. package/dist/tagma.d.ts +13 -4
  69. package/dist/tagma.d.ts.map +1 -1
  70. package/dist/tagma.js +7 -2
  71. package/dist/tagma.js.map +1 -1
  72. package/dist/triggers/file.d.ts.map +1 -1
  73. package/dist/triggers/file.js +74 -107
  74. package/dist/triggers/file.js.map +1 -1
  75. package/dist/validate-raw.d.ts.map +1 -1
  76. package/dist/validate-raw.js +1 -101
  77. package/dist/validate-raw.js.map +1 -1
  78. package/package.json +15 -4
  79. package/src/adapters/stdin-approval.ts +1 -106
  80. package/src/adapters/websocket-approval.ts +1 -224
  81. package/src/approval.ts +5 -127
  82. package/src/bootstrap.ts +24 -15
  83. package/src/core/run-context.test.ts +47 -0
  84. package/src/core/run-context.ts +4 -0
  85. package/src/core/task-executor.ts +28 -45
  86. package/src/engine-ports-mixed.test.ts +70 -44
  87. package/src/engine-ports.test.ts +77 -33
  88. package/src/engine.ts +21 -439
  89. package/src/index.ts +7 -4
  90. package/src/logger.ts +2 -182
  91. package/src/package-split.test.ts +15 -0
  92. package/src/pipeline-runner.test.ts +65 -12
  93. package/src/plugin-registry.test.ts +207 -4
  94. package/src/plugins.ts +6 -3
  95. package/src/registry.ts +7 -298
  96. package/src/runner.ts +1 -666
  97. package/src/runtime/adapters/stdin-approval.ts +1 -0
  98. package/src/runtime/adapters/websocket-approval.ts +1 -0
  99. package/src/runtime/bun-process-runner.ts +1 -0
  100. package/src/runtime-adapters.test.ts +10 -0
  101. package/src/runtime.ts +12 -0
  102. package/src/schema-ports.test.ts +23 -0
  103. package/src/schema.ts +1 -7
  104. package/src/tagma.test.ts +234 -1
  105. package/src/tagma.ts +24 -4
  106. package/src/triggers/file.test.ts +79 -0
  107. package/src/triggers/file.ts +85 -118
  108. package/src/validate-raw.ts +1 -117
package/dist/logger.js CHANGED
@@ -1,154 +1,2 @@
1
- import { resolve, dirname } from 'node:path';
2
- import { mkdirSync, writeFileSync, openSync, writeSync, closeSync } from 'node:fs';
3
- const TASK_PREFIX_RE = /\[task:([^\]]+)\]/;
4
- function taskIdFromPrefix(prefix) {
5
- const m = TASK_PREFIX_RE.exec(prefix);
6
- return m ? m[1] : null;
7
- }
8
- /**
9
- * Dual-channel logger.
10
- *
11
- * - `info/warn/error` → console AND file (brief, user-visible events)
12
- * - `debug` → file ONLY (verbose diagnostics)
13
- * - `section` → file ONLY (visual separators)
14
- * - `quiet` → file ONLY (bulk payload like full stdout dumps)
15
- *
16
- * Log file path: <workDir>/.tagma/logs/<runId>/pipeline.log (one file per pipeline run,
17
- * truncated on construction). Every line is also forwarded to the optional
18
- * `onLine` callback as a structured `LogRecord`, so callers that want to
19
- * stream the run process over IPC/SSE don't need to tail the file.
20
- */
21
- export class Logger {
22
- filePath;
23
- runDir;
24
- onLine;
25
- /** Persistent file descriptor for append writes (avoids open/close per line). */
26
- fd;
27
- constructor(workDir, runId, onLine) {
28
- this.runDir = resolve(workDir, '.tagma', 'logs', runId);
29
- this.filePath = resolve(this.runDir, 'pipeline.log');
30
- this.onLine = onLine ?? null;
31
- mkdirSync(dirname(this.filePath), { recursive: true });
32
- const header = `# Pipeline run ${runId} @ ${new Date().toISOString()}\n` +
33
- `# Host: ${process.platform} ${process.arch} Bun: ${process.versions.bun ?? 'n/a'}\n` +
34
- `# Work dir: ${workDir}\n\n`;
35
- writeFileSync(this.filePath, header);
36
- // Open once for all subsequent appends (O_APPEND is implied by 'a' flag)
37
- this.fd = openSync(this.filePath, 'a');
38
- }
39
- info(prefix, message) {
40
- const ts = timestamp();
41
- const line = `${ts} ${prefix} ${message}`;
42
- // eslint-disable-next-line no-console
43
- console.log(line);
44
- this.emit('info', ts, line, taskIdFromPrefix(prefix));
45
- this.append(line);
46
- }
47
- warn(prefix, message) {
48
- const ts = timestamp();
49
- const line = `${ts} ${prefix} WARN: ${message}`;
50
- console.warn(line);
51
- this.emit('warn', ts, line, taskIdFromPrefix(prefix));
52
- this.append(line);
53
- }
54
- error(prefix, message) {
55
- const ts = timestamp();
56
- const line = `${ts} ${prefix} ERROR: ${message}`;
57
- console.error(line);
58
- this.emit('error', ts, line, taskIdFromPrefix(prefix));
59
- this.append(line);
60
- }
61
- /** File-only diagnostic log line. */
62
- debug(prefix, message) {
63
- const ts = timestamp();
64
- const line = `${ts} ${prefix} DEBUG: ${message}`;
65
- this.emit('debug', ts, line, taskIdFromPrefix(prefix));
66
- this.append(line);
67
- }
68
- /** File-only visual separator with title. */
69
- section(title, taskId) {
70
- const ts = timestamp();
71
- const text = `\n━━━ ${title} ━━━`;
72
- this.emit('section', ts, text, taskId ?? null);
73
- this.append(text);
74
- }
75
- /** File-only bulk payload (e.g. full stdout / stderr dumps). */
76
- quiet(message, taskId) {
77
- const ts = timestamp();
78
- this.emit('quiet', ts, message, taskId ?? null);
79
- this.append(message);
80
- }
81
- append(line) {
82
- if (this.fd === null)
83
- return;
84
- try {
85
- const data = line.endsWith('\n') ? line : line + '\n';
86
- writeSync(this.fd, data);
87
- }
88
- catch {
89
- // Swallow log write failures; engine correctness shouldn't depend on logging.
90
- }
91
- }
92
- /** Close the persistent file handle. Called by the engine at run completion. */
93
- close() {
94
- if (this.fd !== null) {
95
- try {
96
- closeSync(this.fd);
97
- }
98
- catch {
99
- /* already closed */
100
- }
101
- this.fd = null;
102
- }
103
- }
104
- emit(level, ts, text, taskId) {
105
- if (!this.onLine)
106
- return;
107
- try {
108
- this.onLine({ level, taskId, timestamp: ts, text });
109
- }
110
- catch {
111
- // Never let a listener error derail the pipeline.
112
- }
113
- }
114
- get path() {
115
- return this.filePath;
116
- }
117
- /** Directory that holds all artifacts for this run (pipeline.log, *.stderr, etc.). */
118
- get dir() {
119
- return this.runDir;
120
- }
121
- }
122
- function timestamp() {
123
- const d = new Date();
124
- const hh = String(d.getHours()).padStart(2, '0');
125
- const mm = String(d.getMinutes()).padStart(2, '0');
126
- const ss = String(d.getSeconds()).padStart(2, '0');
127
- const ms = String(d.getMilliseconds()).padStart(3, '0');
128
- return `${hh}:${mm}:${ss}.${ms}`;
129
- }
130
- /** Return the last `n` non-empty lines of `text`, joined with newlines. */
131
- export function tailLines(text, n) {
132
- if (!text)
133
- return '';
134
- const lines = text.split(/\r?\n/).filter((l) => l.length > 0);
135
- return lines.slice(-n).join('\n');
136
- }
137
- /**
138
- * Truncate a blob to at most `maxBytes` UTF-8 bytes for log embedding,
139
- * appending a marker when truncation occurred.
140
- * Uses TextEncoder so CJK and emoji (multi-byte) characters are counted correctly.
141
- */
142
- export function clip(text, maxBytes = 16 * 1024) {
143
- if (!text)
144
- return '';
145
- const encoder = new TextEncoder();
146
- const bytes = encoder.encode(text);
147
- if (bytes.length <= maxBytes)
148
- return text;
149
- const omittedBytes = bytes.length - maxBytes;
150
- // TextDecoder handles partial code-point boundaries safely (replacement char insertion)
151
- const truncated = new TextDecoder().decode(bytes.slice(0, maxBytes));
152
- return truncated + `\n…[truncated ${omittedBytes} bytes]`;
153
- }
1
+ export { clip, Logger, tailLines } from '@tagma/core';
154
2
  //# sourceMappingURL=logger.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAoBnF,MAAM,cAAc,GAAG,mBAAmB,CAAC;AAE3C,SAAS,gBAAgB,CAAC,MAAc;IACtC,MAAM,CAAC,GAAG,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACtC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AACzB,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,MAAM;IACA,QAAQ,CAAS;IACjB,MAAM,CAAS;IACf,MAAM,CAAqB;IAC5C,iFAAiF;IACzE,EAAE,CAAgB;IAE1B,YAAY,OAAe,EAAE,KAAa,EAAE,MAAoB;QAC9D,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;QACxD,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;QACrD,IAAI,CAAC,MAAM,GAAG,MAAM,IAAI,IAAI,CAAC;QAC7B,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACvD,MAAM,MAAM,GACV,kBAAkB,KAAK,MAAM,IAAI,IAA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,SAAS,CAAC;AAC5D,CAAC"}
1
+ {"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC"}
package/dist/plugins.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { bootstrapBuiltins } from './bootstrap';
2
- export { PluginRegistry, isValidPluginName, PLUGIN_NAME_RE, readPluginManifest, } from './registry';
3
- export type { RegisterResult } from './registry';
4
- export type { PluginCategory, PluginModule, PluginManifest, DriverPlugin, TriggerPlugin, CompletionPlugin, MiddlewarePlugin, } from './types';
2
+ export { PluginRegistry, isValidPluginName, PLUGIN_NAME_RE, readPluginManifest, } from '@tagma/core';
3
+ export type { RegisteredCapability, RegisterResult } from '@tagma/core';
4
+ export type { CapabilityHandler, PluginCategory, PluginCapabilities, PluginModule, PluginManifest, PluginSetupContext, TagmaPlugin, DriverPlugin, TriggerPlugin, CompletionPlugin, MiddlewarePlugin, } from './types';
5
5
  //# sourceMappingURL=plugins.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"plugins.d.ts","sourceRoot":"","sources":["../src/plugins.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,cAAc,EACd,kBAAkB,GACnB,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACjD,YAAY,EACV,cAAc,EACd,YAAY,EACZ,cAAc,EACd,YAAY,EACZ,aAAa,EACb,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,SAAS,CAAC"}
1
+ {"version":3,"file":"plugins.d.ts","sourceRoot":"","sources":["../src/plugins.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,cAAc,EACd,kBAAkB,GACnB,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AACxE,YAAY,EACV,iBAAiB,EACjB,cAAc,EACd,kBAAkB,EAClB,YAAY,EACZ,cAAc,EACd,kBAAkB,EAClB,WAAW,EACX,YAAY,EACZ,aAAa,EACb,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,SAAS,CAAC"}
package/dist/plugins.js CHANGED
@@ -1,3 +1,3 @@
1
1
  export { bootstrapBuiltins } from './bootstrap';
2
- export { PluginRegistry, isValidPluginName, PLUGIN_NAME_RE, readPluginManifest, } from './registry';
2
+ export { PluginRegistry, isValidPluginName, PLUGIN_NAME_RE, readPluginManifest, } from '@tagma/core';
3
3
  //# sourceMappingURL=plugins.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"plugins.js","sourceRoot":"","sources":["../src/plugins.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,cAAc,EACd,kBAAkB,GACnB,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"plugins.js","sourceRoot":"","sources":["../src/plugins.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,cAAc,EACd,kBAAkB,GACnB,MAAM,aAAa,CAAC"}
@@ -1,61 +1,3 @@
1
- import type { PluginCategory, DriverPlugin, TriggerPlugin, CompletionPlugin, MiddlewarePlugin, PluginManifest } from './types';
2
- type PluginType = DriverPlugin | TriggerPlugin | CompletionPlugin | MiddlewarePlugin;
3
- export type RegisterResult = 'registered' | 'replaced' | 'unchanged';
4
- export declare const PLUGIN_NAME_RE: RegExp;
5
- export declare function isValidPluginName(name: unknown): name is string;
6
- /**
7
- * Parse and validate the `tagmaPlugin` field of a `package.json` blob.
8
- *
9
- * Returns the strongly-typed manifest if the field is present and
10
- * well-formed (`category` is one of the four known categories and `type`
11
- * is a non-empty string). Returns `null` if the field is absent �?that
12
- * is the host's signal that the package is a library, not a plugin.
13
- *
14
- * Throws if the field is present but malformed: that's a packaging bug
15
- * the plugin author should hear about loudly, not a silent skip.
16
- *
17
- * Hosts use this during auto-discovery to decide whether to load a
18
- * package as a plugin without having to dynamically `import()` it.
19
- */
20
- export declare function readPluginManifest(pkgJson: unknown): PluginManifest | null;
21
- /**
22
- * Instance-scoped plugin registry. Each workspace in a multi-tenant sidecar
23
- * owns its own PluginRegistry, so installing/uninstalling a driver in one
24
- * workspace cannot clobber another.
25
- */
26
- export declare class PluginRegistry {
27
- private readonly registries;
28
- /**
29
- * Register a plugin under (category, type). Returns:
30
- * - 'registered' on first registration
31
- * - 'replaced' when an existing entry was overwritten with a different handler
32
- * - 'unchanged' when the same handler instance was already present
33
- *
34
- * Throws if `category` is unknown, `type` is empty, or `handler` violates
35
- * the minimum interface contract for the category.
36
- */
37
- registerPlugin<T extends PluginType>(category: PluginCategory, type: string, handler: T): RegisterResult;
38
- /**
39
- * Remove a plugin from the in-process registry. Returns true if a plugin
40
- * was actually removed. Note: ESM module caching is not affected, so
41
- * re-importing the same file after unregister will yield the cached module �? * callers wanting a fresh load must restart the host process.
42
- */
43
- unregisterPlugin(category: PluginCategory, type: string): boolean;
44
- getHandler<T extends PluginType>(category: PluginCategory, type: string): T;
45
- hasHandler(category: PluginCategory, type: string): boolean;
46
- listRegistered(category: PluginCategory): string[];
47
- /**
48
- * Load and register a list of plugin packages into this registry.
49
- *
50
- * @param pluginNames - Validated npm package names to load.
51
- * @param resolveFrom - Optional absolute path to resolve plugins from (e.g.
52
- * the workspace's working directory). When omitted, the default ESM
53
- * resolution uses the SDK's own `node_modules`, which will fail for
54
- * plugins installed only in the user's workspace. CLI callers should
55
- * pass `process.cwd()` or the workspace root so that workspace-local
56
- * plugins resolve correctly.
57
- */
58
- loadPlugins(pluginNames: readonly string[], resolveFrom?: string): Promise<void>;
59
- }
60
- export {};
1
+ export { isValidPluginName, PluginRegistry, PLUGIN_NAME_RE, readPluginManifest, } from '@tagma/core';
2
+ export type { RegisteredCapability, RegisterResult } from '@tagma/core';
61
3
  //# sourceMappingURL=registry.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,cAAc,EACd,YAAY,EACZ,aAAa,EACb,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,EACf,MAAM,SAAS,CAAC;AAEjB,KAAK,UAAU,GAAG,YAAY,GAAG,aAAa,GAAG,gBAAgB,GAAG,gBAAgB,CAAC;AA2GrF,MAAM,MAAM,cAAc,GAAG,YAAY,GAAG,UAAU,GAAG,WAAW,CAAC;AAKrE,eAAO,MAAM,cAAc,QAA4D,CAAC;AAExF,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,MAAM,CAE/D;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,GAAG,cAAc,GAAG,IAAI,CAwB1E;AAED;;;;GAIG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,QAAQ,CAAC,UAAU,CAKzB;IAEF;;;;;;;;OAQG;IACH,cAAc,CAAC,CAAC,SAAS,UAAU,EACjC,QAAQ,EAAE,cAAc,EACxB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,CAAC,GACT,cAAc;IAiCjB;;;;OAIG;IACH,gBAAgB,CAAC,QAAQ,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO;IAKjE,UAAU,CAAC,CAAC,SAAS,UAAU,EAAE,QAAQ,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC;IAW3E,UAAU,CAAC,QAAQ,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO;IAI3D,cAAc,CAAC,QAAQ,EAAE,cAAc,GAAG,MAAM,EAAE;IAIlD;;;;;;;;;;OAUG;IACG,WAAW,CACf,WAAW,EAAE,SAAS,MAAM,EAAE,EAC9B,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,IAAI,CAAC;CA0BjB"}
1
+ {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,cAAc,EACd,kBAAkB,GACnB,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC"}
package/dist/registry.js CHANGED
@@ -1,254 +1,2 @@
1
- import { createRequire } from 'node:module';
2
- import { pathToFileURL } from 'node:url';
3
- const VALID_CATEGORIES = new Set([
4
- 'drivers',
5
- 'triggers',
6
- 'completions',
7
- 'middlewares',
8
- ]);
9
- const PLUGIN_TYPE_RE = /^[A-Za-z_][A-Za-z0-9_-]*$/;
10
- function singularCategory(category) {
11
- switch (category) {
12
- case 'drivers':
13
- return 'driver';
14
- case 'triggers':
15
- return 'trigger';
16
- case 'completions':
17
- return 'completion';
18
- case 'middlewares':
19
- return 'middleware';
20
- }
21
- }
22
- /**
23
- * Minimal contract enforcement so a malformed plugin fails fast at
24
- * registration time rather than crashing the engine mid-run.
25
- *
26
- * For drivers we materialize `capabilities` and assert each field is a
27
- * boolean �?otherwise a plugin author can write
28
- * get capabilities() { throw new Error('boom') }
29
- * and pass the basic typeof check, then crash preflight when the engine
30
- * touches `driver.capabilities.sessionResume`. (R8)
31
- */
32
- function validateContract(category, handler) {
33
- if (!handler || typeof handler !== 'object') {
34
- throw new Error(`Plugin handler for category "${category}" must be an object`);
35
- }
36
- const h = handler;
37
- if (typeof h.name !== 'string' || h.name.length === 0) {
38
- throw new Error(`Plugin handler for category "${category}" must declare a non-empty "name"`);
39
- }
40
- switch (category) {
41
- case 'drivers': {
42
- if (typeof h.buildCommand !== 'function') {
43
- throw new Error(`drivers plugin "${h.name}" must export buildCommand()`);
44
- }
45
- // Materialize capabilities �?this triggers any throwing getter NOW
46
- // instead of during preflight.
47
- let caps;
48
- try {
49
- caps = h.capabilities;
50
- }
51
- catch (err) {
52
- throw new Error(`drivers plugin "${h.name}" capabilities accessor threw: ` +
53
- (err instanceof Error ? err.message : String(err)));
54
- }
55
- if (!caps || typeof caps !== 'object') {
56
- throw new Error(`drivers plugin "${h.name}" must declare capabilities object`);
57
- }
58
- const c = caps;
59
- for (const field of ['sessionResume', 'systemPrompt', 'outputFormat']) {
60
- if (typeof c[field] !== 'boolean') {
61
- throw new Error(`drivers plugin "${h.name}".capabilities.${field} must be a boolean (got ${typeof c[field]})`);
62
- }
63
- }
64
- // Optional methods, but if present must be functions.
65
- for (const opt of ['parseResult', 'resolveModel', 'resolveTools']) {
66
- if (h[opt] !== undefined && typeof h[opt] !== 'function') {
67
- throw new Error(`drivers plugin "${h.name}".${opt} must be a function or undefined`);
68
- }
69
- }
70
- break;
71
- }
72
- case 'triggers':
73
- if (typeof h.watch !== 'function') {
74
- throw new Error(`triggers plugin "${h.name}" must export watch()`);
75
- }
76
- break;
77
- case 'completions':
78
- if (typeof h.check !== 'function') {
79
- throw new Error(`completions plugin "${h.name}" must export check()`);
80
- }
81
- break;
82
- case 'middlewares':
83
- // A middleware must provide at least one entry point. `enhanceDoc` is
84
- // the structured PromptDocument API (preferred); `enhance` is the
85
- // legacy string-in/string-out API the engine still supports for
86
- // v0.x plugins. Requiring only `enhance` here rejects every built-in
87
- // and every plugin written against the current types.
88
- if (typeof h.enhanceDoc !== 'function' && typeof h.enhance !== 'function') {
89
- throw new Error(`middlewares plugin "${h.name}" must export enhanceDoc() or enhance()`);
90
- }
91
- if (h.enhanceDoc !== undefined && typeof h.enhanceDoc !== 'function') {
92
- throw new Error(`middlewares plugin "${h.name}".enhanceDoc must be a function or undefined`);
93
- }
94
- if (h.enhance !== undefined && typeof h.enhance !== 'function') {
95
- throw new Error(`middlewares plugin "${h.name}".enhance must be a function or undefined`);
96
- }
97
- break;
98
- }
99
- }
100
- // Plugin name must be a scoped npm package or a tagma-prefixed package.
101
- // Reject absolute/relative paths and suspicious patterns to prevent
102
- // arbitrary code execution via crafted YAML configs.
103
- export const PLUGIN_NAME_RE = /^(@[a-z0-9-]+\/[a-z0-9._-]+|tagma-plugin-[a-z0-9._-]+)$/;
104
- export function isValidPluginName(name) {
105
- return typeof name === 'string' && PLUGIN_NAME_RE.test(name);
106
- }
107
- /**
108
- * Parse and validate the `tagmaPlugin` field of a `package.json` blob.
109
- *
110
- * Returns the strongly-typed manifest if the field is present and
111
- * well-formed (`category` is one of the four known categories and `type`
112
- * is a non-empty string). Returns `null` if the field is absent �?that
113
- * is the host's signal that the package is a library, not a plugin.
114
- *
115
- * Throws if the field is present but malformed: that's a packaging bug
116
- * the plugin author should hear about loudly, not a silent skip.
117
- *
118
- * Hosts use this during auto-discovery to decide whether to load a
119
- * package as a plugin without having to dynamically `import()` it.
120
- */
121
- export function readPluginManifest(pkgJson) {
122
- if (!pkgJson || typeof pkgJson !== 'object')
123
- return null;
124
- const raw = pkgJson.tagmaPlugin;
125
- if (raw === undefined)
126
- return null;
127
- if (!raw || typeof raw !== 'object') {
128
- throw new Error('tagmaPlugin field must be an object with { category, type }');
129
- }
130
- const m = raw;
131
- const category = m.category;
132
- const type = m.type;
133
- if (typeof category !== 'string' || !VALID_CATEGORIES.has(category)) {
134
- throw new Error(`tagmaPlugin.category must be one of ${[...VALID_CATEGORIES].join(', ')}, got ${JSON.stringify(category)}`);
135
- }
136
- if (typeof type !== 'string' || type.length === 0) {
137
- throw new Error(`tagmaPlugin.type must be a non-empty string, got ${JSON.stringify(type)}`);
138
- }
139
- if (!PLUGIN_TYPE_RE.test(type)) {
140
- throw new Error(`tagmaPlugin.type must match ${PLUGIN_TYPE_RE} (letters, digits, underscores, hyphens; no paths or dots), got ${JSON.stringify(type)}`);
141
- }
142
- return { category: category, type };
143
- }
144
- /**
145
- * Instance-scoped plugin registry. Each workspace in a multi-tenant sidecar
146
- * owns its own PluginRegistry, so installing/uninstalling a driver in one
147
- * workspace cannot clobber another.
148
- */
149
- export class PluginRegistry {
150
- registries = {
151
- drivers: new Map(),
152
- triggers: new Map(),
153
- completions: new Map(),
154
- middlewares: new Map(),
155
- };
156
- /**
157
- * Register a plugin under (category, type). Returns:
158
- * - 'registered' on first registration
159
- * - 'replaced' when an existing entry was overwritten with a different handler
160
- * - 'unchanged' when the same handler instance was already present
161
- *
162
- * Throws if `category` is unknown, `type` is empty, or `handler` violates
163
- * the minimum interface contract for the category.
164
- */
165
- registerPlugin(category, type, handler) {
166
- if (!VALID_CATEGORIES.has(category)) {
167
- throw new Error(`Unknown plugin category "${category}"`);
168
- }
169
- if (typeof type !== 'string' || type.length === 0) {
170
- throw new Error(`Plugin type must be a non-empty string (category="${category}")`);
171
- }
172
- if (!PLUGIN_TYPE_RE.test(type)) {
173
- throw new Error(`Plugin type "${type}" must match ${PLUGIN_TYPE_RE} (letters, digits, underscores, hyphens; no paths or dots)`);
174
- }
175
- validateContract(category, handler);
176
- const registry = this.registries[category];
177
- const existing = registry.get(type);
178
- if (existing === handler)
179
- return 'unchanged';
180
- const wasReplaced = existing !== undefined;
181
- registry.set(type, handler);
182
- if (wasReplaced) {
183
- // D18: surface silent shadowing. Hot-reload flows legitimately replace
184
- // handlers; installing two different plugin packages that both claim
185
- // the same (category, type) does not �?the second wins and breaks the
186
- // first's consumers with no audit trail. A console.warn is cheap,
187
- // respects existing callers that rely on 'replaced', and gives ops a
188
- // grep-able signal when registrations collide unexpectedly.
189
- console.warn(`[tagma-sdk] registerPlugin: replaced existing ${category}/${type} �?` +
190
- `check for duplicate plugin packages claiming the same type.`);
191
- }
192
- return wasReplaced ? 'replaced' : 'registered';
193
- }
194
- /**
195
- * Remove a plugin from the in-process registry. Returns true if a plugin
196
- * was actually removed. Note: ESM module caching is not affected, so
197
- * re-importing the same file after unregister will yield the cached module �? * callers wanting a fresh load must restart the host process.
198
- */
199
- unregisterPlugin(category, type) {
200
- if (!VALID_CATEGORIES.has(category))
201
- return false;
202
- return this.registries[category].delete(type);
203
- }
204
- getHandler(category, type) {
205
- const handler = this.registries[category].get(type);
206
- if (!handler) {
207
- throw new Error(`${category} type "${type}" not registered.\n` +
208
- `Install the plugin: bun add @tagma/${singularCategory(category)}-${type}`);
209
- }
210
- return handler;
211
- }
212
- hasHandler(category, type) {
213
- return this.registries[category].has(type);
214
- }
215
- listRegistered(category) {
216
- return [...this.registries[category].keys()];
217
- }
218
- /**
219
- * Load and register a list of plugin packages into this registry.
220
- *
221
- * @param pluginNames - Validated npm package names to load.
222
- * @param resolveFrom - Optional absolute path to resolve plugins from (e.g.
223
- * the workspace's working directory). When omitted, the default ESM
224
- * resolution uses the SDK's own `node_modules`, which will fail for
225
- * plugins installed only in the user's workspace. CLI callers should
226
- * pass `process.cwd()` or the workspace root so that workspace-local
227
- * plugins resolve correctly.
228
- */
229
- async loadPlugins(pluginNames, resolveFrom) {
230
- for (const name of pluginNames) {
231
- if (!isValidPluginName(name)) {
232
- throw new Error(`Plugin "${name}" rejected: plugin names must be scoped npm packages ` +
233
- `(e.g. @tagma/trigger-xyz) or tagma-plugin-* packages. ` +
234
- `Relative/absolute paths are not allowed.`);
235
- }
236
- let moduleUrl = name;
237
- if (resolveFrom) {
238
- // Resolve the package entry point relative to the caller's directory
239
- // so plugins installed in the workspace's node_modules are found
240
- // even when the SDK itself lives elsewhere (e.g. a global install
241
- // or a monorepo sibling package).
242
- const req = createRequire(resolveFrom.endsWith('/') ? resolveFrom : resolveFrom + '/');
243
- const resolved = req.resolve(name);
244
- moduleUrl = pathToFileURL(resolved).href;
245
- }
246
- const mod = await import(moduleUrl);
247
- if (!mod.pluginCategory || !mod.pluginType || !mod.default) {
248
- throw new Error(`Plugin "${name}" must export pluginCategory, pluginType, and default`);
249
- }
250
- this.registerPlugin(mod.pluginCategory, mod.pluginType, mod.default);
251
- }
252
- }
253
- }
1
+ export { isValidPluginName, PluginRegistry, PLUGIN_NAME_RE, readPluginManifest, } from '@tagma/core';
254
2
  //# sourceMappingURL=registry.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"registry.js","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAYzC,MAAM,gBAAgB,GAAgC,IAAI,GAAG,CAAC;IAC5D,SAAS;IACT,UAAU;IACV,aAAa;IACb,aAAa;CACd,CAAC,CAAC;AACH,MAAM,cAAc,GAAG,2BAA2B,CAAC;AAEnD,SAAS,gBAAgB,CAAC,QAAwB;IAChD,QAAQ,QAAQ,EAAE,CAAC;QACjB,KAAK,SAAS;YACZ,OAAO,QAAQ,CAAC;QAClB,KAAK,UAAU;YACb,OAAO,SAAS,CAAC;QACnB,KAAK,aAAa;YAChB,OAAO,YAAY,CAAC;QACtB,KAAK,aAAa;YAChB,OAAO,YAAY,CAAC;IACxB,CAAC;AACH,CAAC;AAED;;;;;;;;;GASG;AACH,SAAS,gBAAgB,CAAC,QAAwB,EAAE,OAAgB;IAClE,IAAI,CAAC,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QAC5C,MAAM,IAAI,KAAK,CAAC,gCAAgC,QAAQ,qBAAqB,CAAC,CAAC;IACjF,CAAC;IACD,MAAM,CAAC,GAAG,OAAkC,CAAC;IAC7C,IAAI,OAAO,CAAC,CAAC,IAAI,KAAK,QAAQ,IAAI,CAAC,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACtD,MAAM,IAAI,KAAK,CAAC,gCAAgC,QAAQ,mCAAmC,CAAC,CAAC;IAC/F,CAAC;IACD,QAAQ,QAAQ,EAAE,CAAC;QACjB,KAAK,SAAS,CAAC,CAAC,CAAC;YACf,IAAI,OAAO,CAAC,CAAC,YAAY,KAAK,UAAU,EAAE,CAAC;gBACz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AI,WAAW,EAAE,CAAC;YAC/B,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,EAAE,CAAC;gBAC7B,MAAM,IAAI,KAAK,CACb,WAAW,IAAI,uDAAuD;oBACpE,wDAAwD;oBACxD,0CAA0C,CAC7C,CAAC;YACJ,CAAC;YACD,IAAI,SAAS,GAAW,IAAI,CAAC;YAC7B,IAAI,WAAW,EAAE,CAAC;gBAChB,qEAAqE;gBACrE,iEAAiE;gBACjE,kEAAkE;gBAClE,kCAAkC;gBAClC,MAAM,GAAG,GAAG,aAAa,CAAC,WAAW,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,WAAW,GAAG,GAAG,CAAC,CAAC;gBACvF,MAAM,QAAQ,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;gBACnC,SAAS,GAAG,aAAa,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC;YAC3C,CAAC;YACD,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,SAAS,CAAC,CAAC;YACpC,IAAI,CAAC,GAAG,CAAC,cAAc,IAAI,CAAC,GAAG,CAAC,UAAU,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;gBAC3D,MAAM,IAAI,KAAK,CAAC,WAAW,IAAI,uDAAuD,CAAC,CAAC;YAC1F,CAAC;YACD,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,cAAc,EAAE,GAAG,CAAC,UAAU,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;QACvE,CAAC;IACH,CAAC;CACF"}
1
+ {"version":3,"file":"registry.js","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,cAAc,EACd,kBAAkB,GACnB,MAAM,aAAa,CAAC"}
package/dist/runner.d.ts CHANGED
@@ -1,36 +1,2 @@
1
- import type { SpawnSpec, DriverPlugin, TaskResult } from './types';
2
- export interface RunOptions {
3
- readonly timeoutMs?: number;
4
- readonly signal?: AbortSignal;
5
- /**
6
- * If set, stream the child's stdout to this file path as it arrives. The
7
- * returned `TaskResult.stdout` is still a bounded in-memory tail
8
- * (`maxStdoutTailBytes`) — callers that need the full output should read
9
- * from the returned `stdoutPath`. Parent directories are created as needed.
10
- */
11
- readonly stdoutPath?: string;
12
- /** Symmetric to `stdoutPath` for stderr. */
13
- readonly stderrPath?: string;
14
- /**
15
- * Cap on bytes retained in memory for the returned `TaskResult.stdout`
16
- * string. Defaults to `DEFAULT_STDOUT_TAIL_BYTES`. Bytes beyond this cap
17
- * from the HEAD of the stream are dropped from the in-memory string; the
18
- * on-disk file (if `stdoutPath` is set) is still the full output.
19
- */
20
- readonly maxStdoutTailBytes?: number;
21
- readonly maxStderrTailBytes?: number;
22
- }
23
- /**
24
- * R2: Validate a SpawnSpec returned by a third-party driver. Returns null on
25
- * success or a human-readable error message describing the first violation.
26
- *
27
- * Catching this here is critical: an undetected bad spec ends up calling
28
- * Bun.spawn with garbage and the resulting TypeError leaks into engine
29
- * processTask's catch block as "Cannot read properties of undefined". By
30
- * validating here we surface a clear "Driver X returned invalid args" message
31
- * instead, and short-circuit before holding any process resources.
32
- */
33
- export declare function validateSpawnSpec(spec: unknown, driverName: string): string | null;
34
- export declare function runSpawn(spec: SpawnSpec, driver: DriverPlugin | null, opts?: RunOptions): Promise<TaskResult>;
35
- export declare function runCommand(command: string, cwd: string, opts?: RunOptions): Promise<TaskResult>;
1
+ export { runCommand, runSpawn } from '@tagma/runtime-bun';
36
2
  //# sourceMappingURL=runner.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../src/runner.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AA4CnE,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;IAC9B;;;;;OAKG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,4CAA4C;IAC5C,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B;;;;;OAKG;IACH,QAAQ,CAAC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IACrC,QAAQ,CAAC,kBAAkB,CAAC,EAAE,MAAM,CAAC;CACtC;AA4SD;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAoClF;AAED,wBAAsB,QAAQ,CAC5B,IAAI,EAAE,SAAS,EACf,MAAM,EAAE,YAAY,GAAG,IAAI,EAC3B,IAAI,GAAE,UAAe,GACpB,OAAO,CAAC,UAAU,CAAC,CA0OrB;AAED,wBAAsB,UAAU,CAC9B,OAAO,EAAE,MAAM,EACf,GAAG,EAAE,MAAM,EACX,IAAI,GAAE,UAAe,GACpB,OAAO,CAAC,UAAU,CAAC,CAMrB"}
1
+ {"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../src/runner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC"}