terse-cli 0.9.19 → 0.9.21

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 (126) hide show
  1. package/README.md +2 -2
  2. package/dist/cliUi.d.ts +3 -1
  3. package/dist/cliUi.d.ts.map +1 -1
  4. package/dist/cliUi.js +3 -2
  5. package/dist/cliUi.js.map +1 -1
  6. package/dist/commands/actor.d.ts.map +1 -1
  7. package/dist/commands/actor.js +32 -5
  8. package/dist/commands/actor.js.map +1 -1
  9. package/dist/commands/actorGenerate.d.ts.map +1 -1
  10. package/dist/commands/actorGenerate.js +22 -86
  11. package/dist/commands/actorGenerate.js.map +1 -1
  12. package/dist/commands/attach.d.ts +0 -7
  13. package/dist/commands/attach.d.ts.map +1 -1
  14. package/dist/commands/attach.js +220 -189
  15. package/dist/commands/attach.js.map +1 -1
  16. package/dist/commands/deploy.d.ts.map +1 -1
  17. package/dist/commands/deploy.js +15 -3
  18. package/dist/commands/deploy.js.map +1 -1
  19. package/dist/commands/generate.d.ts +0 -4
  20. package/dist/commands/generate.d.ts.map +1 -1
  21. package/dist/commands/generate.js +161 -127
  22. package/dist/commands/generate.js.map +1 -1
  23. package/dist/commands/history.d.ts +0 -15
  24. package/dist/commands/history.d.ts.map +1 -1
  25. package/dist/commands/history.js +139 -105
  26. package/dist/commands/history.js.map +1 -1
  27. package/dist/commands/install.d.ts.map +1 -1
  28. package/dist/commands/install.js +6 -4
  29. package/dist/commands/install.js.map +1 -1
  30. package/dist/commands/integrate.d.ts +0 -48
  31. package/dist/commands/integrate.d.ts.map +1 -1
  32. package/dist/commands/integrate.js +897 -699
  33. package/dist/commands/integrate.js.map +1 -1
  34. package/dist/commands/integrateUse.d.ts +0 -12
  35. package/dist/commands/integrateUse.d.ts.map +1 -1
  36. package/dist/commands/integrateUse.js +132 -98
  37. package/dist/commands/integrateUse.js.map +1 -1
  38. package/dist/commands/listen.d.ts +0 -7
  39. package/dist/commands/listen.d.ts.map +1 -1
  40. package/dist/commands/listen.js +98 -81
  41. package/dist/commands/listen.js.map +1 -1
  42. package/dist/commands/memory.d.ts +0 -21
  43. package/dist/commands/memory.d.ts.map +1 -1
  44. package/dist/commands/memory.js +147 -128
  45. package/dist/commands/memory.js.map +1 -1
  46. package/dist/commands/replay.d.ts +0 -2
  47. package/dist/commands/replay.d.ts.map +1 -1
  48. package/dist/commands/replay.js +37 -28
  49. package/dist/commands/replay.js.map +1 -1
  50. package/dist/commands/resume.d.ts +0 -4
  51. package/dist/commands/resume.d.ts.map +1 -1
  52. package/dist/commands/resume.js +34 -28
  53. package/dist/commands/resume.js.map +1 -1
  54. package/dist/commands/run.d.ts +0 -2
  55. package/dist/commands/run.d.ts.map +1 -1
  56. package/dist/commands/run.js +78 -70
  57. package/dist/commands/run.js.map +1 -1
  58. package/dist/commands/state.d.ts +0 -18
  59. package/dist/commands/state.d.ts.map +1 -1
  60. package/dist/commands/state.js +129 -108
  61. package/dist/commands/state.js.map +1 -1
  62. package/dist/commands/test.d.ts +0 -28
  63. package/dist/commands/test.d.ts.map +1 -1
  64. package/dist/commands/test.js +509 -403
  65. package/dist/commands/test.js.map +1 -1
  66. package/dist/commands/toolRun.d.ts +0 -6
  67. package/dist/commands/toolRun.d.ts.map +1 -1
  68. package/dist/commands/toolRun.js +149 -134
  69. package/dist/commands/toolRun.js.map +1 -1
  70. package/dist/index.js +1 -1
  71. package/dist/index.js.map +1 -1
  72. package/dist/integrationApi.d.ts +0 -15
  73. package/dist/integrationApi.d.ts.map +1 -1
  74. package/dist/integrationApi.js +75 -49
  75. package/dist/integrationApi.js.map +1 -1
  76. package/dist/loadJob.d.ts +0 -11
  77. package/dist/loadJob.d.ts.map +1 -1
  78. package/dist/loadJob.js +54 -46
  79. package/dist/loadJob.js.map +1 -1
  80. package/dist/providers/LanguageProvider.d.ts +0 -29
  81. package/dist/providers/LanguageProvider.d.ts.map +1 -1
  82. package/dist/providers/LanguageProvider.js +3 -0
  83. package/dist/providers/LanguageProvider.js.map +1 -1
  84. package/dist/providers/typescript/TypeScriptProvider.d.ts +0 -24
  85. package/dist/providers/typescript/TypeScriptProvider.d.ts.map +1 -1
  86. package/dist/providers/typescript/TypeScriptProvider.js +113 -113
  87. package/dist/providers/typescript/TypeScriptProvider.js.map +1 -1
  88. package/dist/providers/typescript/runtimes/JobRuntime.d.ts +0 -26
  89. package/dist/providers/typescript/runtimes/JobRuntime.d.ts.map +1 -1
  90. package/dist/providers/typescript/runtimes/JobRuntime.js +51 -18
  91. package/dist/providers/typescript/runtimes/JobRuntime.js.map +1 -1
  92. package/dist/providers/typescript/runtimes/directJobRuntime.d.ts +0 -2
  93. package/dist/providers/typescript/runtimes/directJobRuntime.d.ts.map +1 -1
  94. package/dist/providers/typescript/runtimes/directJobRuntime.js +60 -49
  95. package/dist/providers/typescript/runtimes/directJobRuntime.js.map +1 -1
  96. package/dist/providers/typescript/runtimes/durableJobRuntime.d.ts +0 -2
  97. package/dist/providers/typescript/runtimes/durableJobRuntime.d.ts.map +1 -1
  98. package/dist/providers/typescript/runtimes/durableJobRuntime.js +168 -146
  99. package/dist/providers/typescript/runtimes/durableJobRuntime.js.map +1 -1
  100. package/dist/providers/typescript/runtimes/index.d.ts +0 -3
  101. package/dist/providers/typescript/runtimes/index.d.ts.map +1 -1
  102. package/dist/providers/typescript/runtimes/index.js +5 -2
  103. package/dist/providers/typescript/runtimes/index.js.map +1 -1
  104. package/dist/providers/typescript/runtimes/session.d.ts +0 -4
  105. package/dist/providers/typescript/runtimes/session.d.ts.map +1 -1
  106. package/dist/providers/typescript/runtimes/session.js +78 -64
  107. package/dist/providers/typescript/runtimes/session.js.map +1 -1
  108. package/dist/providers/typescript/terseWorkflow.d.ts +0 -7
  109. package/dist/providers/typescript/terseWorkflow.d.ts.map +1 -1
  110. package/dist/providers/typescript/terseWorkflow.js +12 -7
  111. package/dist/providers/typescript/terseWorkflow.js.map +1 -1
  112. package/dist/runLocalTestJob.d.ts +0 -19
  113. package/dist/runLocalTestJob.d.ts.map +1 -1
  114. package/dist/runLocalTestJob.js +55 -29
  115. package/dist/runLocalTestJob.js.map +1 -1
  116. package/dist/setup.js +1 -1
  117. package/dist/setup.js.map +1 -1
  118. package/dist/sourceArchive.d.ts +1 -1
  119. package/dist/sourceArchive.d.ts.map +1 -1
  120. package/dist/sourceArchive.js +1 -0
  121. package/dist/sourceArchive.js.map +1 -1
  122. package/package.json +3 -4
  123. package/templates/typescript/init/package.json.hbs +1 -2
  124. package/templates/typescript/terse-transport.d.ts +25 -0
  125. package/templates/typescript/terse-transport.js +117 -0
  126. package/templates/typescript/tsconfig.json +13 -0
@@ -1,5 +1 @@
1
- import type { LanguageProvider } from "../providers/LanguageProvider.js";
2
- export declare function generate(provider?: LanguageProvider, opts?: {
3
- apiKey?: string;
4
- }): Promise<void>;
5
1
  //# sourceMappingURL=generate.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../src/commands/generate.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAiB,gBAAgB,EAAE,MAAM,kCAAkC,CAAA;AAQvF,wBAAsB,QAAQ,CAAC,QAAQ,GAAE,gBAAoC,EAAE,IAAI,CAAC,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAcxH"}
1
+ {"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../src/commands/generate.ts"],"names":[],"mappings":""}
@@ -1,128 +1,162 @@
1
- import { intro, log } from "@clack/prompts";
2
- import chalk from "chalk";
3
- import fs from "node:fs";
4
- import path from "node:path";
5
- import { ApiRoutes, IntegrationType, isValidToolName, toolDefinitionsResponseSchema } from "terse-types";
6
- import { ApiError, fetchWithAuth, readApiKeyOrBail } from "../api.js";
7
- import { assertProjectRoot } from "../assertProjectRoot.js";
8
- import { CliError, ErrorCode } from "../cliError.js";
9
- import { createSpinner, formatSummaryList } from "../cliUi.js";
10
- import { fetchIntegrations } from "../integrationApi.js";
11
- import { readProjectConfig } from "../projectConfig.js";
12
- import { resolveProvider } from "../providers/resolveProvider.js";
13
- // Platform-native integrations have no connected instance, so they never appear in the org's active
14
- // integrations. Their tools are always generated; availability is still gated by skills at runtime.
15
- const PLATFORM_NATIVE_INTEGRATIONS = new Set([IntegrationType.TERSE]);
16
- export async function generate(provider = resolveProvider(), opts) {
17
- intro("terse generate");
18
- assertProjectRoot(provider, provider.detectionMarkers);
19
- const totalStart = performance.now();
20
- const s = createSpinner();
21
- s.start("Checking authentication");
22
- try {
23
- await generateFiles(provider, opts, s, totalStart);
24
- }
25
- catch (error) {
26
- s.stop(error instanceof CliError && error.code === "pinned_connection_missing" ? "Pinned connection missing" : "Code generation failed");
27
- throw error;
28
- }
29
- }
30
- async function generateFiles(provider, opts, s, totalStart) {
31
- const apiKey = opts?.apiKey?.trim() ||
32
- readApiKeyOrBail({
33
- title: "\n Not authenticated.\n",
34
- detail: " Run `terse auth login` to authenticate, or set TERSE_API_KEY in your environment.\n"
35
- });
36
- s.message("Fetching integrations");
37
- let activeTypes;
38
- try {
39
- activeTypes = await fetchWithAuth(ApiRoutes.INTEGRATIONS.ACTIVE, apiKey);
40
- }
41
- catch (error) {
42
- const message = String(error?.message || "");
43
- const isAuthError = (error instanceof ApiError && (error.status === 401 || error.status === 403)) ||
44
- message.includes("401") ||
45
- message.includes("403") ||
46
- message.toLowerCase().includes("authentication failed") ||
47
- message.toLowerCase().includes("unauthorized") ||
48
- message.toLowerCase().includes("forbidden");
49
- if (isAuthError) {
50
- throw new CliError("not_authenticated", "Authentication failed: your TERSE_API_KEY was rejected.", {
51
- detail: "Run `terse auth login` to refresh your credentials and try again.",
52
- actionRequired: true,
53
- exitCode: ErrorCode.BAD_ARGUMENTS
54
- });
55
- }
56
- throw new CliError("fetch_integrations_failed", message || "Failed to fetch integrations.");
57
- }
58
- s.message("Fetching integration catalog");
59
- let availableIntegrations = [];
60
- try {
61
- const catalog = await fetchIntegrations(apiKey);
62
- availableIntegrations = [...new Set(catalog.map(entry => entry.integrationType))].sort();
63
- }
64
- catch {
65
- log.warn("Skipped integration catalog fetch; proceeding without the available-integrations list");
66
- }
67
- s.message("Fetching tool definitions");
68
- let toolDefs = [];
69
- try {
70
- const raw = await fetchWithAuth(ApiRoutes.SDK.TOOL_DEFINITIONS, apiKey);
71
- const resp = toolDefinitionsResponseSchema.parse(raw);
72
- const activeSet = new Set(activeTypes);
73
- toolDefs = resp.tools.filter(t => activeSet.has(t.integration) || PLATFORM_NATIVE_INTEGRATIONS.has(t.integration));
74
- const skippedToolNames = [...new Set(toolDefs.filter(t => !isValidToolName(t.name)).map(t => t.name))].sort();
75
- toolDefs = toolDefs.filter(t => isValidToolName(t.name));
76
- if (skippedToolNames.length > 0) {
77
- log.warn(`Skipped ${skippedToolNames.length} tool(s) absent from terse-types ToolDefinitions: ${skippedToolNames.join(", ")}`);
78
- }
79
- }
80
- catch {
81
- log.warn("Skipped tool definitions fetch; proceeding without typed tool wrappers");
82
- }
83
- s.message("Fetching integration details");
84
- const codegenTimer = { start: performance.now() };
85
- const result = await provider.renderGeneratedFiles({
86
- apiKey,
87
- activeTypes,
88
- availableIntegrations,
89
- tools: toolDefs,
90
- activeConnections: readProjectConfig()?.connections ?? {}
91
- }, {
92
- onFetchComplete: () => {
93
- s.message("Generating code");
94
- codegenTimer.start = performance.now();
95
- }
96
- });
97
- const codegenMs = performance.now() - codegenTimer.start;
98
- s.message("Writing generated files");
99
- writeOutput(result.files, provider);
100
- const integrationCount = result.integrationSummaries.reduce((sum, summary) => sum + summary.instanceCount, 0);
101
- s.stop(`Fetched ${integrationCount} integration(s)`);
102
- const totalMs = performance.now() - totalStart;
103
- const integrationSummary = formatSummaryList(result.integrationSummaries.map(summary => labelWithCount(summary.label, summary.instanceCount)), 10);
104
- if (integrationSummary) {
105
- console.log(chalk.dim(`Integrations: ${integrationSummary}`));
106
- }
107
- if (toolDefs.length > 0) {
108
- console.log(chalk.dim(`Generated types for ${toolDefs.length} ${toolDefs.length === 1 ? "tool" : "tools"}`));
109
- }
110
- const generatedPath = path.relative(process.cwd(), provider.resolveGeneratedCodePath(process.cwd()));
111
- console.log(chalk.dim(result.files.length > 1
112
- ? `Generated ${generatedPath} + ${result.files.length - 1} file(s) under ${path.join(path.dirname(generatedPath), "terse.generated")}/`
113
- : `Generated ${generatedPath}`));
114
- console.log(chalk.dim(`Codegen: ${codegenMs.toFixed(0)}ms | Total: ${totalMs.toFixed(0)}ms`));
115
- }
116
- function writeOutput(files, provider) {
117
- const outputDir = path.dirname(provider.resolveGeneratedCodePath(process.cwd()));
118
- fs.rmSync(path.join(outputDir, "terse.generated"), { recursive: true, force: true });
119
- for (const file of files) {
120
- const target = path.join(outputDir, file.fileName);
121
- fs.mkdirSync(path.dirname(target), { recursive: true });
122
- fs.writeFileSync(target, file.code);
123
- }
124
- }
125
- function labelWithCount(label, count) {
126
- return count === 1 ? label : `${label} (${count})`;
127
- }
1
+ "use strict";
2
+ // LEGACY-JOBS: Commented out while Terse is actors-only. Uncomment to restore; see the note in terse-sdk/src/index.ts.
3
+ // import { intro, log, outro } from "@clack/prompts"
4
+ // import chalk from "chalk"
5
+ // import fs from "node:fs"
6
+ // import path from "node:path"
7
+ // import { ApiRoutes, IntegrationType, type ToolDefinition, isValidToolName, toolDefinitionsResponseSchema } from "terse-types"
8
+ //
9
+ // import { ApiError, fetchWithAuth, readApiKeyOrBail } from "../api.js"
10
+ // import { assertProjectRoot } from "../assertProjectRoot.js"
11
+ // import { CliError, ErrorCode } from "../cliError.js"
12
+ // import { createSpinner, formatSummaryList } from "../cliUi.js"
13
+ // import { fetchIntegrations } from "../integrationApi.js"
14
+ // import { readProjectConfig } from "../projectConfig.js"
15
+ // import type { GeneratedFile, LanguageProvider } from "../providers/LanguageProvider.js"
16
+ // import type { CodegenResult } from "../providers/codegenTypes.js"
17
+ // import { resolveProvider } from "../providers/resolveProvider.js"
18
+ //
19
+ // // Platform-native integrations have no connected instance, so they never appear in the org's active
20
+ // // integrations. Their tools are always generated; availability is still gated by skills at runtime.
21
+ // const PLATFORM_NATIVE_INTEGRATIONS = new Set<string>([IntegrationType.TERSE])
22
+ //
23
+ // export async function generate(provider: LanguageProvider = resolveProvider(), opts?: { apiKey?: string }): Promise<void> {
24
+ // intro("terse generate")
25
+ // assertProjectRoot(provider, provider.detectionMarkers)
26
+ //
27
+ // const totalStart = performance.now()
28
+ // const s = createSpinner()
29
+ //
30
+ // s.start("Checking authentication")
31
+ // try {
32
+ // await generateFiles(provider, opts, s, totalStart)
33
+ // } catch (error) {
34
+ // s.stop(error instanceof CliError && error.code === "pinned_connection_missing" ? "Pinned connection missing" : "Code generation failed")
35
+ // throw error
36
+ // }
37
+ // }
38
+ //
39
+ // async function generateFiles(provider: LanguageProvider, opts: { apiKey?: string } | undefined, s: ReturnType<typeof createSpinner>, totalStart: number): Promise<void> {
40
+ // const apiKey =
41
+ // opts?.apiKey?.trim() ||
42
+ // readApiKeyOrBail({
43
+ // title: "\n Not authenticated.\n",
44
+ // detail: " Run `terse auth login` to authenticate, or set TERSE_API_KEY in your environment.\n"
45
+ // })
46
+ //
47
+ // s.message("Fetching integrations")
48
+ //
49
+ // let activeTypes: IntegrationType[]
50
+ // try {
51
+ // activeTypes = await fetchWithAuth<IntegrationType[]>(ApiRoutes.INTEGRATIONS.ACTIVE, apiKey)
52
+ // } catch (error: any) {
53
+ // const message = String(error?.message || "")
54
+ // const isAuthError =
55
+ // (error instanceof ApiError && (error.status === 401 || error.status === 403)) ||
56
+ // message.includes("401") ||
57
+ // message.includes("403") ||
58
+ // message.toLowerCase().includes("authentication failed") ||
59
+ // message.toLowerCase().includes("unauthorized") ||
60
+ // message.toLowerCase().includes("forbidden")
61
+ //
62
+ // if (isAuthError) {
63
+ // throw new CliError("not_authenticated", "Authentication failed: your TERSE_API_KEY was rejected.", {
64
+ // detail: "Run `terse auth login` to refresh your credentials and try again.",
65
+ // actionRequired: true,
66
+ // exitCode: ErrorCode.BAD_ARGUMENTS
67
+ // })
68
+ // }
69
+ //
70
+ // throw new CliError("fetch_integrations_failed", message || "Failed to fetch integrations.")
71
+ // }
72
+ //
73
+ // s.message("Fetching integration catalog")
74
+ //
75
+ // let availableIntegrations: string[] = []
76
+ // try {
77
+ // const catalog = await fetchIntegrations(apiKey)
78
+ // availableIntegrations = [...new Set(catalog.map(entry => entry.integrationType))].sort()
79
+ // } catch {
80
+ // log.warn("Skipped integration catalog fetch; proceeding without the available-integrations list")
81
+ // }
82
+ //
83
+ // s.message("Fetching tool definitions")
84
+ //
85
+ // let toolDefs: ToolDefinition[] = []
86
+ // try {
87
+ // const raw = await fetchWithAuth<unknown>(ApiRoutes.SDK.TOOL_DEFINITIONS, apiKey)
88
+ // const resp = toolDefinitionsResponseSchema.parse(raw)
89
+ // const activeSet = new Set(activeTypes as string[])
90
+ // toolDefs = resp.tools.filter(t => activeSet.has(t.integration) || PLATFORM_NATIVE_INTEGRATIONS.has(t.integration))
91
+ // const skippedToolNames = [...new Set(toolDefs.filter(t => !isValidToolName(t.name)).map(t => t.name))].sort()
92
+ // toolDefs = toolDefs.filter(t => isValidToolName(t.name))
93
+ // if (skippedToolNames.length > 0) {
94
+ // log.warn(`Skipped ${skippedToolNames.length} tool(s) absent from terse-types ToolDefinitions: ${skippedToolNames.join(", ")}`)
95
+ // }
96
+ // } catch {
97
+ // log.warn("Skipped tool definitions fetch; proceeding without typed tool wrappers")
98
+ // }
99
+ //
100
+ // s.message("Fetching integration details")
101
+ //
102
+ // const codegenTimer = { start: performance.now() }
103
+ // const result: CodegenResult = await provider.renderGeneratedFiles(
104
+ // {
105
+ // apiKey,
106
+ // activeTypes,
107
+ // availableIntegrations,
108
+ // tools: toolDefs,
109
+ // activeConnections: readProjectConfig()?.connections ?? {}
110
+ // },
111
+ // {
112
+ // onFetchComplete: () => {
113
+ // s.message("Generating code")
114
+ // codegenTimer.start = performance.now()
115
+ // }
116
+ // }
117
+ // )
118
+ // const codegenMs = performance.now() - codegenTimer.start
119
+ //
120
+ // s.message("Writing generated files")
121
+ // writeOutput(result.files, provider)
122
+ //
123
+ // const integrationCount = result.integrationSummaries.reduce((sum, summary) => sum + summary.instanceCount, 0)
124
+ // s.stop(`Fetched ${integrationCount} integration(s)`)
125
+ //
126
+ // const totalMs = performance.now() - totalStart
127
+ // const integrationSummary = formatSummaryList(
128
+ // result.integrationSummaries.map(summary => labelWithCount(summary.label, summary.instanceCount)),
129
+ // 10
130
+ // )
131
+ //
132
+ // if (integrationSummary) {
133
+ // console.log(chalk.dim(`Integrations: ${integrationSummary}`))
134
+ // }
135
+ // if (toolDefs.length > 0) {
136
+ // console.log(chalk.dim(`Generated types for ${toolDefs.length} ${toolDefs.length === 1 ? "tool" : "tools"}`))
137
+ // }
138
+ // const generatedPath = path.relative(process.cwd(), provider.resolveGeneratedCodePath(process.cwd()))
139
+ // console.log(
140
+ // chalk.dim(
141
+ // result.files.length > 1
142
+ // ? `Generated ${generatedPath} + ${result.files.length - 1} file(s) under ${path.join(path.dirname(generatedPath), "terse.generated")}/`
143
+ // : `Generated ${generatedPath}`
144
+ // )
145
+ // )
146
+ // console.log(chalk.dim(`Codegen: ${codegenMs.toFixed(0)}ms | Total: ${totalMs.toFixed(0)}ms`))
147
+ // }
148
+ //
149
+ // function writeOutput(files: GeneratedFile[], provider: LanguageProvider): void {
150
+ // const outputDir = path.dirname(provider.resolveGeneratedCodePath(process.cwd()))
151
+ // fs.rmSync(path.join(outputDir, "terse.generated"), { recursive: true, force: true })
152
+ // for (const file of files) {
153
+ // const target = path.join(outputDir, file.fileName)
154
+ // fs.mkdirSync(path.dirname(target), { recursive: true })
155
+ // fs.writeFileSync(target, file.code)
156
+ // }
157
+ // }
158
+ //
159
+ // function labelWithCount(label: string, count: number): string {
160
+ // return count === 1 ? label : `${label} (${count})`
161
+ // }
128
162
  //# sourceMappingURL=generate.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"generate.js","sourceRoot":"","sources":["../../src/commands/generate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE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;AAChE,6DAA6D;AAC7D,6HAA6H;AAC7H,wHAAwH;AACxH,mEAAmE;AACnE,6CAA6C;AAC7C,6IAA6I;AAC7I,YAAY;AACZ,gBAAgB;AAChB,6FAA6F;AAC7F,QAAQ;AACR,EAAE;AACF,gDAAgD;AAChD,EAAE;AACF,wDAAwD;AACxD,yEAAyE;AACzE,YAAY;AACZ,sBAAsB;AACtB,2BAA2B;AAC3B,qCAAqC;AACrC,+BAA+B;AAC/B,wEAAwE;AACxE,aAAa;AACb,YAAY;AACZ,uCAAuC;AACvC,+CAA+C;AAC/C,yDAAyD;AACzD,gBAAgB;AAChB,YAAY;AACZ,QAAQ;AACR,+DAA+D;AAC/D,EAAE;AACF,2CAA2C;AAC3C,0CAA0C;AAC1C,EAAE;AACF,oHAAoH;AACpH,2DAA2D;AAC3D,EAAE;AACF,qDAAqD;AACrD,oDAAoD;AACpD,4GAA4G;AAC5G,aAAa;AACb,QAAQ;AACR,EAAE;AACF,gCAAgC;AAChC,wEAAwE;AACxE,QAAQ;AACR,iCAAiC;AACjC,uHAAuH;AACvH,QAAQ;AACR,2GAA2G;AAC3G,mBAAmB;AACnB,qBAAqB;AACrB,sCAAsC;AACtC,0JAA0J;AAC1J,iDAAiD;AACjD,YAAY;AACZ,QAAQ;AACR,oGAAoG;AACpG,IAAI;AACJ,EAAE;AACF,mFAAmF;AACnF,uFAAuF;AACvF,2FAA2F;AAC3F,kCAAkC;AAClC,6DAA6D;AAC7D,kEAAkE;AAClE,8CAA8C;AAC9C,QAAQ;AACR,IAAI;AACJ,EAAE;AACF,kEAAkE;AAClE,yDAAyD;AACzD,IAAI"}
@@ -1,16 +1 @@
1
- import { LanguageProvider } from "../providers/LanguageProvider.js";
2
- export declare function history(jobName?: string, options?: HistoryOptions, provider?: LanguageProvider): Promise<void>;
3
- export type HistoryOptions = {
4
- json?: boolean;
5
- limit?: number;
6
- page?: number;
7
- status?: string;
8
- since?: string;
9
- until?: string;
10
- query?: string;
11
- triggers?: boolean;
12
- events?: boolean;
13
- runId?: string;
14
- includeTest?: boolean;
15
- };
16
1
  //# sourceMappingURL=history.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"history.d.ts","sourceRoot":"","sources":["../../src/commands/history.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAA;AAQnE,wBAAsB,OAAO,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,OAAO,GAAE,cAAmB,EAAE,QAAQ,GAAE,gBAAoC,GAAG,OAAO,CAAC,IAAI,CAAC,CAgF3I;AA4BD,MAAM,MAAM,cAAc,GAAG;IACzB,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,WAAW,CAAC,EAAE,OAAO,CAAA;CACxB,CAAA"}
1
+ {"version":3,"file":"history.d.ts","sourceRoot":"","sources":["../../src/commands/history.ts"],"names":[],"mappings":""}
@@ -1,106 +1,140 @@
1
- import chalk from "chalk";
2
- import ora from "ora";
3
- import { RunHistoryStatus } from "terse-types";
4
- import { fetchRunChatHistory, fetchRunHistory, readApiKeyOrBail, resolveAgentIdByJobName, resolveEventFromRunId } from "../api.js";
5
- import { CliError } from "../cliError.js";
6
- import { loadJob } from "../loadJob.js";
7
- import { resolveProvider } from "../providers/resolveProvider.js";
8
- import { printRunChat, printRuns } from "./historyPrinters.js";
9
- const VALID_STATUSES = new Set(Object.values(RunHistoryStatus));
10
- const MAX_PAGE_SIZE = 100;
11
- export async function history(jobName, options = {}, provider = resolveProvider()) {
12
- const apiKey = readApiKeyOrBail();
13
- // Single-run mode bypasses job/agent resolution.
14
- if (options.runId) {
15
- const chat = await fetchRunChatHistory(options.runId, apiKey);
16
- if (options.json) {
17
- process.stdout.write(JSON.stringify({ runId: options.runId, ...chat }, null, 2) + "\n");
18
- return;
19
- }
20
- printRunChat(options.runId, chat);
21
- return;
22
- }
23
- const { job } = await loadJob(provider, jobName);
24
- const spinner = options.json ? null : ora(`Fetching run history for ${job.name}`).start();
25
- let agentId;
26
- try {
27
- agentId = await resolveAgentIdByJobName(job.name, apiKey);
28
- }
29
- catch (error) {
30
- spinner?.fail(chalk.red("Failed to look up job"));
31
- throw error;
32
- }
33
- if (!agentId) {
34
- spinner?.fail(chalk.red(`Job "${job.name}" is not deployed`));
35
- throw new CliError("no_deployed_agent", `Job "${job.name}" is not deployed`, {
36
- detail: "Have you run `terse deploy` for this job?"
37
- });
38
- }
39
- const params = buildParams(options);
40
- const response = await fetchRunHistory(agentId, apiKey, params);
41
- let items = response.items;
42
- // --triggers: cheap per-run fetch of just the input event JSON via /sdk/runs/:runId/trigger-event.
43
- // Implied by --events (which fetches the full chat history including the trigger payload).
44
- if (options.triggers && !options.events && items.length > 0) {
45
- if (spinner)
46
- spinner.text = `Fetching trigger events for ${items.length} run${items.length === 1 ? "" : "s"}`;
47
- items = await Promise.all(items.map(async (run) => {
48
- const triggerEvent = await resolveEventFromRunId(run.id, apiKey);
49
- return triggerEvent ? { ...run, triggerEvent: triggerEvent.event } : run;
50
- }));
51
- }
52
- // --events: full chat history per run (model events + trigger event). Heavier than --triggers.
53
- if (options.events && items.length > 0) {
54
- if (spinner)
55
- spinner.text = `Fetching chat events for ${items.length} run${items.length === 1 ? "" : "s"}`;
56
- items = await Promise.all(items.map(async (run) => {
57
- try {
58
- const chat = await fetchRunChatHistory(run.id, apiKey);
59
- return { ...run, chat };
60
- }
61
- catch {
62
- return run;
63
- }
64
- }));
65
- }
66
- spinner?.succeed(`Fetched ${items.length} of ${response.total} run${response.total === 1 ? "" : "s"} for ${job.name}`);
67
- if (options.json) {
68
- const payload = {
69
- jobName: job.name,
70
- agentId,
71
- page: response.page,
72
- pageSize: response.pageSize,
73
- total: response.total,
74
- items
75
- };
76
- process.stdout.write(JSON.stringify(payload, null, 2) + "\n");
77
- return;
78
- }
79
- printRuns(job.name, agentId, items, response.total);
80
- }
81
- function buildParams(options) {
82
- const params = {};
83
- if (options.query)
84
- params.q = options.query;
85
- if (options.since)
86
- params.start = options.since;
87
- if (options.until)
88
- params.end = options.until;
89
- if (options.page && options.page > 0)
90
- params.page = options.page;
91
- if (options.includeTest)
92
- params.includeTest = true;
93
- if (options.limit && options.limit > 0) {
94
- params.pageSize = Math.min(options.limit, MAX_PAGE_SIZE);
95
- }
96
- if (options.status) {
97
- const statuses = options.status
98
- .split(",")
99
- .map(s => s.trim())
100
- .filter((s) => VALID_STATUSES.has(s));
101
- if (statuses.length > 0)
102
- params.status = statuses;
103
- }
104
- return params;
105
- }
1
+ "use strict";
2
+ // LEGACY-JOBS: Commented out while Terse is actors-only. Uncomment to restore; see the note in terse-sdk/src/index.ts.
3
+ // import chalk from "chalk"
4
+ // import ora from "ora"
5
+ // import { RunHistoryStatus } from "terse-types"
6
+ // import type { GetRunHistoryParams, RunHistoryStatus as RunHistoryStatusType } from "terse-types"
7
+ //
8
+ // import { fetchRunChatHistory, fetchRunHistory, readApiKeyOrBail, resolveAgentIdByJobName, resolveEventFromRunId } from "../api.js"
9
+ // import { CliError } from "../cliError.js"
10
+ // import { loadJob } from "../loadJob.js"
11
+ // import { LanguageProvider } from "../providers/LanguageProvider.js"
12
+ // import { resolveProvider } from "../providers/resolveProvider.js"
13
+ //
14
+ // import { type RunWithEvents, printRunChat, printRuns } from "./historyPrinters.js"
15
+ //
16
+ // const VALID_STATUSES = new Set<RunHistoryStatusType>(Object.values(RunHistoryStatus) as RunHistoryStatusType[])
17
+ // const MAX_PAGE_SIZE = 100
18
+ //
19
+ // export async function history(jobName?: string, options: HistoryOptions = {}, provider: LanguageProvider = resolveProvider()): Promise<void> {
20
+ // const apiKey = readApiKeyOrBail()
21
+ //
22
+ // // Single-run mode bypasses job/agent resolution.
23
+ // if (options.runId) {
24
+ // const chat = await fetchRunChatHistory(options.runId, apiKey)
25
+ // if (options.json) {
26
+ // process.stdout.write(JSON.stringify({ runId: options.runId, ...chat }, null, 2) + "\n")
27
+ // return
28
+ // }
29
+ // printRunChat(options.runId, chat)
30
+ // return
31
+ // }
32
+ //
33
+ // const { job } = await loadJob(provider, jobName)
34
+ //
35
+ // const spinner = options.json ? null : ora(`Fetching run history for ${job.name}`).start()
36
+ // let agentId: string | null
37
+ // try {
38
+ // agentId = await resolveAgentIdByJobName(job.name, apiKey)
39
+ // } catch (error) {
40
+ // spinner?.fail(chalk.red("Failed to look up job"))
41
+ // throw error
42
+ // }
43
+ //
44
+ // if (!agentId) {
45
+ // spinner?.fail(chalk.red(`Job "${job.name}" is not deployed`))
46
+ // throw new CliError("no_deployed_agent", `Job "${job.name}" is not deployed`, {
47
+ // detail: "Have you run `terse deploy` for this job?"
48
+ // })
49
+ // }
50
+ //
51
+ // const params = buildParams(options)
52
+ //
53
+ // const response = await fetchRunHistory(agentId, apiKey, params)
54
+ // let items: RunWithEvents[] = response.items
55
+ //
56
+ // // --triggers: cheap per-run fetch of just the input event JSON via /sdk/runs/:runId/trigger-event.
57
+ // // Implied by --events (which fetches the full chat history including the trigger payload).
58
+ // if (options.triggers && !options.events && items.length > 0) {
59
+ // if (spinner) spinner.text = `Fetching trigger events for ${items.length} run${items.length === 1 ? "" : "s"}`
60
+ // items = await Promise.all(
61
+ // items.map(async run => {
62
+ // const triggerEvent = await resolveEventFromRunId(run.id, apiKey)
63
+ // return triggerEvent ? { ...run, triggerEvent: triggerEvent.event } : run
64
+ // })
65
+ // )
66
+ // }
67
+ //
68
+ // // --events: full chat history per run (model events + trigger event). Heavier than --triggers.
69
+ // if (options.events && items.length > 0) {
70
+ // if (spinner) spinner.text = `Fetching chat events for ${items.length} run${items.length === 1 ? "" : "s"}`
71
+ // items = await Promise.all(
72
+ // items.map(async run => {
73
+ // try {
74
+ // const chat = await fetchRunChatHistory(run.id, apiKey)
75
+ // return { ...run, chat }
76
+ // } catch {
77
+ // return run
78
+ // }
79
+ // })
80
+ // )
81
+ // }
82
+ //
83
+ // spinner?.succeed(`Fetched ${items.length} of ${response.total} run${response.total === 1 ? "" : "s"} for ${job.name}`)
84
+ //
85
+ // if (options.json) {
86
+ // const payload = {
87
+ // jobName: job.name,
88
+ // agentId,
89
+ // page: response.page,
90
+ // pageSize: response.pageSize,
91
+ // total: response.total,
92
+ // items
93
+ // }
94
+ // process.stdout.write(JSON.stringify(payload, null, 2) + "\n")
95
+ // return
96
+ // }
97
+ //
98
+ // printRuns(job.name, agentId, items, response.total)
99
+ // }
100
+ //
101
+ // function buildParams(options: HistoryOptions): GetRunHistoryParams {
102
+ // const params: GetRunHistoryParams = {}
103
+ //
104
+ // if (options.query) params.q = options.query
105
+ // if (options.since) params.start = options.since
106
+ // if (options.until) params.end = options.until
107
+ // if (options.page && options.page > 0) params.page = options.page
108
+ // if (options.includeTest) params.includeTest = true
109
+ //
110
+ // if (options.limit && options.limit > 0) {
111
+ // params.pageSize = Math.min(options.limit, MAX_PAGE_SIZE)
112
+ // }
113
+ //
114
+ // if (options.status) {
115
+ // const statuses = options.status
116
+ // .split(",")
117
+ // .map(s => s.trim())
118
+ // .filter((s): s is RunHistoryStatusType => VALID_STATUSES.has(s as RunHistoryStatusType))
119
+ // if (statuses.length > 0) params.status = statuses
120
+ // }
121
+ //
122
+ // return params
123
+ // }
124
+ //
125
+ // // Types
126
+ //
127
+ // export type HistoryOptions = {
128
+ // json?: boolean
129
+ // limit?: number
130
+ // page?: number
131
+ // status?: string
132
+ // since?: string
133
+ // until?: string
134
+ // query?: string
135
+ // triggers?: boolean
136
+ // events?: boolean
137
+ // runId?: string
138
+ // includeTest?: boolean
139
+ // }
106
140
  //# sourceMappingURL=history.js.map