agency-lang 0.12.0 → 0.13.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 (151) hide show
  1. package/dist/lib/backends/agencyGenerator.d.ts +77 -5
  2. package/dist/lib/backends/agencyGenerator.js +324 -165
  3. package/dist/lib/backends/typescriptBuilder.js +16 -0
  4. package/dist/lib/backends/typescriptGenerator/typeToString.d.ts +6 -2
  5. package/dist/lib/backends/typescriptGenerator/typeToString.js +29 -22
  6. package/dist/lib/cli/budget.d.ts +2 -8
  7. package/dist/lib/cli/budget.js +6 -27
  8. package/dist/lib/cli/deploy/bundle.d.ts +13 -7
  9. package/dist/lib/cli/deploy/bundle.js +63 -40
  10. package/dist/lib/cli/deploy/curlExamples.d.ts +4 -5
  11. package/dist/lib/cli/deploy/curlExamples.js +3 -4
  12. package/dist/lib/cli/deploy/deploy.d.ts +2 -2
  13. package/dist/lib/cli/deploy/deploy.js +1 -1
  14. package/dist/lib/cli/deploy/render.js +1 -1
  15. package/dist/lib/cli/eval/label.d.ts +47 -0
  16. package/dist/lib/cli/eval/label.js +118 -0
  17. package/dist/lib/cli/remote/args.d.ts +5 -0
  18. package/dist/lib/cli/remote/args.js +45 -0
  19. package/dist/lib/cli/remote/binding.d.ts +10 -0
  20. package/dist/lib/cli/remote/binding.js +48 -0
  21. package/dist/lib/cli/remote/browser.d.ts +5 -0
  22. package/dist/lib/cli/remote/browser.js +24 -0
  23. package/dist/lib/cli/remote/commands/call.d.ts +11 -0
  24. package/dist/lib/cli/remote/commands/call.js +44 -0
  25. package/dist/lib/cli/remote/commands/deploy.d.ts +8 -0
  26. package/dist/lib/cli/remote/commands/deploy.js +47 -0
  27. package/dist/lib/cli/remote/commands/link.d.ts +4 -0
  28. package/dist/lib/cli/remote/commands/link.js +22 -0
  29. package/dist/lib/cli/remote/commands/ls.d.ts +4 -0
  30. package/dist/lib/cli/remote/commands/ls.js +18 -0
  31. package/dist/lib/cli/remote/commands/open.d.ts +2 -0
  32. package/dist/lib/cli/remote/commands/open.js +14 -0
  33. package/dist/lib/cli/remote/commands/util.d.ts +15 -0
  34. package/dist/lib/cli/remote/commands/util.js +20 -0
  35. package/dist/lib/cli/remote/confirmation.d.ts +6 -0
  36. package/dist/lib/cli/remote/confirmation.js +26 -0
  37. package/dist/lib/cli/remote/decision.d.ts +11 -0
  38. package/dist/lib/cli/remote/decision.js +24 -0
  39. package/dist/lib/cli/remote/exportedEndpoints.d.ts +6 -0
  40. package/dist/lib/cli/remote/exportedEndpoints.js +11 -0
  41. package/dist/lib/cli/remote/render.d.ts +5 -0
  42. package/dist/lib/cli/remote/render.js +36 -0
  43. package/dist/lib/cli/runPolicy.d.ts +9 -2
  44. package/dist/lib/cli/runPolicy.js +1 -1
  45. package/dist/lib/cli/statelog/serveClient.d.ts +33 -0
  46. package/dist/lib/cli/statelog/serveClient.js +174 -0
  47. package/dist/lib/cli/statelog/serveUrl.d.ts +29 -0
  48. package/dist/lib/cli/statelog/serveUrl.js +92 -0
  49. package/dist/lib/cli/{deploy → statelog}/uploadClient.d.ts +4 -14
  50. package/dist/lib/cli/{deploy → statelog}/uploadClient.js +26 -19
  51. package/dist/lib/config.d.ts +28 -0
  52. package/dist/lib/config.js +15 -0
  53. package/dist/lib/duration.d.ts +7 -0
  54. package/dist/lib/duration.js +29 -0
  55. package/dist/lib/eval/label/annotations.d.ts +53 -0
  56. package/dist/lib/eval/label/annotations.js +92 -0
  57. package/dist/lib/eval/label/capture.d.ts +45 -0
  58. package/dist/lib/eval/label/capture.js +219 -0
  59. package/dist/lib/eval/label/checklist.d.ts +107 -0
  60. package/dist/lib/eval/label/checklist.js +335 -0
  61. package/dist/lib/eval/label/controller.d.ts +36 -0
  62. package/dist/lib/eval/label/controller.js +488 -0
  63. package/dist/lib/eval/label/corpus.d.ts +7 -0
  64. package/dist/lib/eval/label/corpus.js +16 -0
  65. package/dist/lib/eval/label/draft.d.ts +148 -0
  66. package/dist/lib/eval/label/draft.js +103 -0
  67. package/dist/lib/eval/label/ids.d.ts +34 -0
  68. package/dist/lib/eval/label/ids.js +58 -0
  69. package/dist/lib/eval/label/jsonl.d.ts +53 -0
  70. package/dist/lib/eval/label/jsonl.js +187 -0
  71. package/dist/lib/eval/label/labelTui.d.ts +92 -0
  72. package/dist/lib/eval/label/labelTui.js +382 -0
  73. package/dist/lib/eval/label/lock.d.ts +27 -0
  74. package/dist/lib/eval/label/lock.js +122 -0
  75. package/dist/lib/eval/label/session.d.ts +130 -0
  76. package/dist/lib/eval/label/session.js +242 -0
  77. package/dist/lib/eval/label/store.d.ts +61 -0
  78. package/dist/lib/eval/label/store.js +268 -0
  79. package/dist/lib/eval/label/types.d.ts +169 -0
  80. package/dist/lib/eval/label/types.js +119 -0
  81. package/dist/lib/parser.js +5 -4
  82. package/dist/lib/parsers/parsers.d.ts +28 -2
  83. package/dist/lib/parsers/parsers.js +354 -49
  84. package/dist/lib/runtime/cliInterruptResolution.d.ts +16 -0
  85. package/dist/lib/runtime/cliInterruptResolution.js +41 -0
  86. package/dist/lib/runtime/configOverrides.d.ts +7 -0
  87. package/dist/lib/runtime/configOverrides.js +17 -0
  88. package/dist/lib/runtime/index.d.ts +1 -1
  89. package/dist/lib/runtime/index.js +1 -1
  90. package/dist/lib/runtime/interruptPrompts.d.ts +17 -0
  91. package/dist/lib/runtime/interruptPrompts.js +110 -0
  92. package/dist/lib/runtime/interruptResolution.d.ts +39 -0
  93. package/dist/lib/runtime/interruptResolution.js +68 -0
  94. package/dist/lib/runtime/interruptResponse.d.ts +11 -0
  95. package/dist/lib/runtime/interruptResponse.js +14 -0
  96. package/dist/lib/runtime/interrupts.d.ts +16 -10
  97. package/dist/lib/runtime/interrupts.js +47 -9
  98. package/dist/lib/runtime/node.js +1 -1
  99. package/dist/lib/runtime/rootBudget.d.ts +11 -2
  100. package/dist/lib/runtime/rootBudget.js +42 -18
  101. package/dist/lib/runtime/runPolicyHandler.d.ts +4 -22
  102. package/dist/lib/runtime/runPolicyHandler.js +16 -168
  103. package/dist/lib/runtime/state/context.d.ts +13 -0
  104. package/dist/lib/runtime/state/context.js +7 -0
  105. package/dist/lib/runtime/trace/canonicalize.d.ts +1 -1
  106. package/dist/lib/runtime/trace/canonicalize.js +5 -17
  107. package/dist/lib/serve/http/adapter.js +6 -2
  108. package/dist/lib/serve/metadata.d.ts +1 -0
  109. package/dist/lib/serve/metadata.js +6 -3
  110. package/dist/lib/stdlib/layout/ansi.js +35 -9
  111. package/dist/lib/tui/input/terminal.d.ts +8 -0
  112. package/dist/lib/tui/input/terminal.js +39 -2
  113. package/dist/lib/tui/screen.d.ts +3 -0
  114. package/dist/lib/tui/screen.js +6 -0
  115. package/dist/lib/tui/styleParser.js +15 -6
  116. package/dist/lib/typeChecker/diagnosticExplanations.js +5 -0
  117. package/dist/lib/typeChecker/diagnostics.d.ts +5 -0
  118. package/dist/lib/typeChecker/diagnostics.js +5 -0
  119. package/dist/lib/typeChecker/index.js +3 -0
  120. package/dist/lib/typeChecker/nameReferences.d.ts +37 -0
  121. package/dist/lib/typeChecker/nameReferences.js +69 -0
  122. package/dist/lib/typeChecker/templateNames.d.ts +31 -0
  123. package/dist/lib/typeChecker/templateNames.js +260 -0
  124. package/dist/lib/typeChecker/undefinedFunctionDiagnostic.js +10 -18
  125. package/dist/lib/typeChecker/undefinedVariableDiagnostic.js +7 -58
  126. package/dist/lib/types/access.d.ts +1 -1
  127. package/dist/lib/types/base.d.ts +10 -0
  128. package/dist/lib/types/dataStructures.d.ts +27 -7
  129. package/dist/lib/types/dataStructures.js +3 -1
  130. package/dist/lib/types/exportFromStatement.d.ts +3 -0
  131. package/dist/lib/types/function.d.ts +5 -0
  132. package/dist/lib/types/graphNode.d.ts +3 -0
  133. package/dist/lib/types/guardBlock.d.ts +3 -0
  134. package/dist/lib/types/hole.d.ts +2 -2
  135. package/dist/lib/types/importStatement.d.ts +5 -0
  136. package/dist/lib/types/interruptStatement.d.ts +3 -0
  137. package/dist/lib/types/matchBlock.d.ts +3 -1
  138. package/dist/lib/types/messageThread.d.ts +3 -0
  139. package/dist/lib/types/parallelBlock.d.ts +3 -0
  140. package/dist/lib/types/pattern.d.ts +5 -0
  141. package/dist/lib/types/typeHints.d.ts +3 -5
  142. package/dist/lib/utils/canonicalize.d.ts +14 -0
  143. package/dist/lib/utils/canonicalize.js +33 -0
  144. package/dist/lib/utils/termcolors.d.ts +2 -0
  145. package/dist/lib/utils/termcolors.js +1 -0
  146. package/dist/scripts/agency.js +66 -19
  147. package/package.json +1 -1
  148. package/stdlib/docs/cli/deploy.md +2 -2
  149. package/stdlib/docs/diagnostics/index.md +1 -0
  150. package/stdlib/docs/diagnostics/templates.md +12 -0
  151. package/stdlib/docs/guide/template-agency.md +34 -0
@@ -1,8 +1,25 @@
1
- import { AgencyComment, AgencyMultiLineComment, AgencyNode, AgencyProgram, Assignment, Comprehension, DebuggerStatement, Hole, InterruptStatement, Literal, NewLine, ObjectTypeTrivia, ParallelBlock, Scope, SeqBlock, TypeAlias, VariableType } from "../types.js";
1
+ import { AgencyComment, AgencyMultiLineComment, AgencyNode, AgencyProgram, Assignment, Comprehension, DebuggerStatement, Hole, InterruptStatement, Literal, NewLine, ParallelBlock, Scope, SeqBlock, TypeAlias, VariableType } from "../types.js";
2
+ import { LineComment } from "../types/base.js";
3
+ import { ListTrivia, TriviaNode } from "../types/dataStructures.js";
4
+ /** One rendered list item. `leadingLines` are whole lines that print above
5
+ * it (an object-type property's `@validate` tags); the shared renderer
6
+ * indents them, so callers hand back plain text. */
7
+ type RenderedListItem = {
8
+ leadingLines?: string[];
9
+ code: string;
10
+ };
11
+ type RenderListWithTriviaOptions<T> = {
12
+ items: T[];
13
+ trivia: ListTrivia[] | undefined;
14
+ open: string;
15
+ close: string;
16
+ renderItem: (item: T, index: number) => RenderedListItem;
17
+ separator: (index: number, itemCount: number) => string;
18
+ };
2
19
  import { AccessChainElement, ValueAccess } from "../types/access.js";
3
20
  import { CodeLiteral } from "../types/codeLiteral.js";
4
21
  import { BlockArgument } from "../types/blockArgument.js";
5
- import { AgencyArray, AgencyObject, Trivia } from "../types/dataStructures.js";
22
+ import { AgencyArray, AgencyObject } from "../types/dataStructures.js";
6
23
  import { FunctionCall, FunctionDefinition } from "../types/function.js";
7
24
  import { GraphNodeDefinition } from "../types/graphNode.js";
8
25
  import { IfElse } from "../types/ifElse.js";
@@ -25,6 +42,7 @@ import { GuardBlock } from "../types/guardBlock.js";
25
42
  import { Tag } from "../types/tag.js";
26
43
  import { NewExpression } from "../types/newExpression.js";
27
44
  import { BindingPattern, MatchPattern } from "../types/pattern.js";
45
+ type TypeRenderPolicy = "source" | "display";
28
46
  export declare function escapeStringText(s: string, delim: '"' | "'" | "`"): string;
29
47
  export declare class AgencyGenerator {
30
48
  protected graphNodes: GraphNodeDefinition[];
@@ -111,13 +129,34 @@ export declare class AgencyGenerator {
111
129
  private increaseIndent;
112
130
  private decreaseIndent;
113
131
  private indentStr;
132
+ /** `renderItems` is a callback, not an array, because a multi-line item has
133
+ * to be built at the depth it will actually print at. Rewriting an
134
+ * already-rendered item's lines instead would reach inside triple-quoted
135
+ * strings, whose newlines are data rather than layout, and silently change
136
+ * the program. So the items are rendered once to measure, and rendered
137
+ * again after the indent increases if the list turns out to wrap. */
114
138
  private wrapList;
115
139
  private renderParams;
140
+ private renderTypeSource;
141
+ private renderTypeDisplay;
142
+ private objectTypeHasPropertyMetadata;
143
+ private renderType;
116
144
  private stringifyProp;
117
- protected emitTriviaAt(trivia: (ObjectTypeTrivia | Trivia)[] | undefined, anchorIndex: number, lines: string[]): void;
118
- protected aliasedTypeToString(aliasedType: VariableType): string;
145
+ /** One trivia node as its own source line. */
146
+ protected renderTriviaNode(node: TriviaNode): string;
147
+ /** Comments that print on their own line ABOVE item `anchorIndex`. */
148
+ protected beforeTriviaAt(trivia: ListTrivia[] | undefined, anchorIndex: number): TriviaNode[];
149
+ /** Comments that print at the END of item `anchorIndex`'s line. */
150
+ protected trailingTriviaAt(trivia: ListTrivia[] | undefined, anchorIndex: number): LineComment[];
151
+ /** Render one multiline list, owning indentation and both comment
152
+ * placements. Callers supply how to render an item and where separators
153
+ * go; they must not place comments themselves. */
154
+ protected renderListWithTrivia<T>(args: RenderListWithTriviaOptions<T>): string;
155
+ protected aliasedTypeToString(aliasedType: VariableType, policy: TypeRenderPolicy): string;
156
+ private renderObjectTypeSource;
119
157
  protected processEffectDeclaration(node: EffectDeclaration): string;
120
158
  protected processTypeAlias(node: TypeAlias): string;
159
+ private composeTypeAliasAssignment;
121
160
  /**
122
161
  * Format the `<T, U = string, ...>` chunk of a generic alias declaration.
123
162
  * Returns an empty string when there are no type params.
@@ -181,13 +220,32 @@ export declare class AgencyGenerator {
181
220
  * node and stripping keywords, so all three kinds share one canonical
182
221
  * signature path. */
183
222
  signatureOf(node: FunctionDefinition | GraphNodeDefinition | TypeAlias): string;
223
+ /** Render the annotations that precede a type alias declaration. */
224
+ declarationAnnotationPrefixOf(node: TypeAlias): string;
184
225
  protected processFunctionDefinition(node: FunctionDefinition): string;
185
226
  protected processFunctionCall(node: FunctionCall): string;
186
227
  protected renderArgs(args: FunctionCall["arguments"], block?: BlockArgument): string[];
187
- protected renderArgList(args: FunctionCall["arguments"], block?: BlockArgument): string;
228
+ /** A list of already-rendered items laid out across lines with its
229
+ * comments, or `undefined` when there are none. Callers keep their own
230
+ * inline or wrapping behavior for the no-comment case, so trivia-free
231
+ * output is untouched; a comment cannot share a line with what follows
232
+ * it, so its presence forces the multiline form. */
233
+ protected renderListIfTrivia(rendered: string[], trivia: ListTrivia[] | undefined, open: string, close: string): string | undefined;
234
+ /** The one way a parenthesized `( ... )` list is printed. Without trivia
235
+ * it keeps `wrapList`'s compact/wrapping behavior exactly; with trivia it
236
+ * goes multiline. `rendered` must already be in canonical print order —
237
+ * for a call that means `renderArgs` has appended any inline block last,
238
+ * matching how `extractInlineBlock` remapped the anchors. */
239
+ protected renderParenList(renderItems: () => string[], trivia: ListTrivia[] | undefined, prefix: string, suffix: string): string;
240
+ /** A parenthesized argument list that normally stays on one line
241
+ * (access chains, `interrupt`, `guard`). Trivia forces the multiline
242
+ * form, since a `//` comment cannot share a line with what follows it. */
243
+ protected renderArgList(args: FunctionCall["arguments"], block?: BlockArgument, trivia?: ListTrivia[]): string;
188
244
  protected generateFunctionCallExpression(node: FunctionCall, context: "valueAccess" | "functionArg" | "topLevelStatement"): string;
189
245
  protected processAgencyArray(node: AgencyArray): string;
246
+ private renderArrayItem;
190
247
  protected processAgencyObject(node: AgencyObject): string;
248
+ private renderObjectEntry;
191
249
  private addQuotesToKey;
192
250
  protected processValueAccess(node: ValueAccess): string;
193
251
  /** Print `[| ... |]`. An expr-kind body that fits one line prints
@@ -200,6 +258,10 @@ export declare class AgencyGenerator {
200
258
  protected processCodeLiteral(node: CodeLiteral): string;
201
259
  protected asyncAwaitPrefix(code: string, async?: boolean): string;
202
260
  protected processMatchBlock(node: MatchBlock): string;
261
+ /** One arm, without its final newline — a complete construct an
262
+ * attached comment can follow. */
263
+ private renderInlineMatchArm;
264
+ private renderBlockMatchArm;
203
265
  /** Whether a one-statement arm body may print inline (`=> stmt`)
204
266
  * rather than as a `{ ... }` block.
205
267
  *
@@ -223,12 +285,21 @@ export declare class AgencyGenerator {
223
285
  protected formatIfExpression(node: IfElse): string;
224
286
  protected processGotoStatement(node: GotoStatement): string;
225
287
  protected processDebuggerStatement(node: DebuggerStatement): string;
288
+ /** The sole owner of line-comment source text. Do not rebuild
289
+ * `//${content}` anywhere else. */
290
+ protected commentText(comment: LineComment): string;
226
291
  protected processComment(node: AgencyComment): string;
292
+ /** Place an attached comment after already-rendered code. Empty code has
293
+ * no construct to attach to, so the comment is left to its owner. */
294
+ protected appendTrailingComment(code: string, comment: LineComment | undefined): string;
227
295
  protected processMultiLineComment(node: AgencyMultiLineComment): string;
228
296
  protected formatDocComment(node: {
229
297
  docComment?: AgencyMultiLineComment;
230
298
  }): string;
231
299
  protected processImportStatement(node: ImportStatement): string;
300
+ /** The names inside an import's `{ ... }`, with their aliases and
301
+ * retry-safety markers. Shared by the sole-named and mixed paths. */
302
+ private renderImportNames;
232
303
  protected processImportNameType(node: ImportNameType): string;
233
304
  /** Render an imported/re-exported name with its `destructive` or
234
305
  * `idempotent` prefix. A name carries at most one marker. */
@@ -280,3 +351,4 @@ export declare function generateAgency(program: AgencyProgram, opts?: {
280
351
  * NOT `expressionToString` (lib/utils/node.ts), which drops string quotes.
281
352
  */
282
353
  export declare function generateExpression(expr: AgencyNode): string;
354
+ export {};