@flow-engineer/flow 0.0.1 → 0.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 (96) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +595 -0
  3. package/coding-agents/skill.md +321 -0
  4. package/coding-agents/test-skill.md +223 -0
  5. package/coding-agents/tools-skill.md +89 -0
  6. package/dist/flow-messaging/src/client.d.ts +34 -0
  7. package/dist/flow-messaging/src/client.js +130 -0
  8. package/dist/flow-messaging/src/index.d.ts +37 -0
  9. package/dist/flow-messaging/src/index.js +409 -0
  10. package/dist/simulators/src/index.d.ts +2 -0
  11. package/dist/simulators/src/index.js +2 -0
  12. package/dist/simulators/src/page.html +1245 -0
  13. package/dist/simulators/src/person.html +100 -0
  14. package/dist/simulators/src/platforms.d.ts +29 -0
  15. package/dist/simulators/src/platforms.js +72 -0
  16. package/dist/simulators/src/server.d.ts +201 -0
  17. package/dist/simulators/src/server.js +759 -0
  18. package/dist/src/agent.d.ts +504 -0
  19. package/dist/src/agent.js +818 -0
  20. package/dist/src/channels.d.ts +178 -0
  21. package/dist/src/channels.js +243 -0
  22. package/dist/src/conversation.d.ts +361 -0
  23. package/dist/src/conversation.js +1487 -0
  24. package/dist/src/db.d.ts +18 -0
  25. package/dist/src/db.js +57 -0
  26. package/dist/src/events.d.ts +17 -0
  27. package/dist/src/events.js +20 -0
  28. package/dist/src/http.d.ts +45 -0
  29. package/dist/src/http.js +269 -0
  30. package/dist/src/index.d.ts +14 -0
  31. package/dist/src/index.js +11 -0
  32. package/dist/src/model.d.ts +21 -0
  33. package/dist/src/model.js +96 -0
  34. package/dist/src/names.d.ts +17 -0
  35. package/dist/src/names.js +38 -0
  36. package/dist/src/nudges.d.ts +23 -0
  37. package/dist/src/nudges.js +117 -0
  38. package/dist/src/postgres.d.ts +20 -0
  39. package/dist/src/postgres.js +62 -0
  40. package/dist/src/schedules.d.ts +60 -0
  41. package/dist/src/schedules.js +249 -0
  42. package/dist/src/skills.d.ts +12 -0
  43. package/dist/src/skills.js +69 -0
  44. package/dist/src/store.d.ts +214 -0
  45. package/dist/src/store.js +448 -0
  46. package/dist/src/talk.d.ts +57 -0
  47. package/dist/src/talk.js +166 -0
  48. package/dist/src/time.d.ts +71 -0
  49. package/dist/src/time.js +170 -0
  50. package/dist/src/tools.d.ts +43 -0
  51. package/dist/src/tools.js +26 -0
  52. package/dist/src/traces.d.ts +31 -0
  53. package/dist/src/traces.js +303 -0
  54. package/dist/src/types.d.ts +260 -0
  55. package/dist/src/types.js +2 -0
  56. package/dist/testing/src/check-endpoint.d.ts +31 -0
  57. package/dist/testing/src/check-endpoint.js +158 -0
  58. package/dist/testing/src/chinwag.d.ts +2 -0
  59. package/dist/testing/src/chinwag.js +6 -0
  60. package/dist/testing/src/cli.d.ts +2 -0
  61. package/dist/testing/src/cli.js +563 -0
  62. package/dist/testing/src/client.d.ts +115 -0
  63. package/dist/testing/src/client.js +955 -0
  64. package/dist/testing/src/http-agent.d.ts +47 -0
  65. package/dist/testing/src/http-agent.js +155 -0
  66. package/dist/testing/src/index.d.ts +3 -0
  67. package/dist/testing/src/index.js +2 -0
  68. package/dist/testing/src/new.d.ts +9 -0
  69. package/dist/testing/src/new.js +122 -0
  70. package/dist/testing/src/print-run.d.ts +3 -0
  71. package/dist/testing/src/print-run.js +22 -0
  72. package/dist/testing/src/protocol.d.ts +159 -0
  73. package/dist/testing/src/protocol.js +28 -0
  74. package/dist/testing/src/report.d.ts +74 -0
  75. package/dist/testing/src/report.js +90 -0
  76. package/dist/testing/src/show.d.ts +36 -0
  77. package/dist/testing/src/show.js +280 -0
  78. package/dist/testing/src/suite.d.ts +87 -0
  79. package/dist/testing/src/suite.js +198 -0
  80. package/examples/cafe/agent/AGENTS.md +10 -0
  81. package/examples/cafe/agent/skills/allergens/SKILL.md +7 -0
  82. package/examples/cafe/src/agent.ts +39 -0
  83. package/examples/cafe/src/main.ts +16 -0
  84. package/examples/cafe/src/tools.ts +62 -0
  85. package/examples/cafe/tests/scenarios/latte-correction.yaml +30 -0
  86. package/examples/cafe/tests/scenarios/order-fails.yaml +26 -0
  87. package/examples/cafe/tests/tools/get_menu.yaml +14 -0
  88. package/examples/cafe/tests/tools/place_order.yaml +29 -0
  89. package/examples/http-agent/server.mjs +32 -0
  90. package/examples/http-agent/tests/scenarios/opening-hours.yaml +16 -0
  91. package/flow-messaging/README.md +152 -0
  92. package/package.json +62 -8
  93. package/spec/agent-endpoint.openapi.yaml +148 -0
  94. package/spec/nudges.openapi.yaml +167 -0
  95. package/spec/request.schema.json +121 -0
  96. package/spec/response.schema.json +284 -0
@@ -0,0 +1,115 @@
1
+ import { type Agent, type EventSink, type Tool } from "../../src/index.ts";
2
+ import type { Opened, RunSummary, SessionSummary } from "./protocol.ts";
3
+ import { type SuiteFile } from "./suite.ts";
4
+ export interface ConnectOptions {
5
+ /** The cloud's address, such as http://127.0.0.1:8900. */
6
+ cloud: string;
7
+ /** A stable key for the agent (its package name), which keeps its history together. */
8
+ name: string;
9
+ /** The agent's name for people, shown in the dashboard. */
10
+ title?: string;
11
+ /** The agent's real tools: only their names, descriptions and inputs are used. */
12
+ tools: Tool[];
13
+ /** Builds the agent with the tools and events it is given: a Flow Framework Agent, or anything that answers like one (http-agent.ts). */
14
+ build: (options: {
15
+ tools: Tool[];
16
+ events: EventSink[];
17
+ }) => AgentUnderTest;
18
+ files: SuiteFile[];
19
+ /** The tests folder: files a scenario attaches are read from here, and never leave this machine. */
20
+ testsDir?: string;
21
+ runs?: number;
22
+ log?: (line: string) => void;
23
+ /** Headers for the open only (cloudHeaders: the CI key and the attestation); never sent to the tunnel. */
24
+ openHeaders?: Record<string, string>;
25
+ /** Called as each run finishes, before the session's summary. An older cloud sends none. */
26
+ onRun?: (run: RunSummary) => void;
27
+ /** Called once the session has opened, with its dashboard link, its id, and the cloud's id for the agent (a hosted cloud answers one). */
28
+ onDashboard?: (url: string, sessionId: string, agent?: string) => void;
29
+ /** How long one POST waits before the size allowance. Default 30s, plus 1s per 100KB of body. A tool call waits {@link CLOUD_MODEL_BUDGET_MS} plus the simulator's latency, unless this is set. */
30
+ postTimeoutMs?: number;
31
+ /** How long the stream may sit with no bytes, including the cloud's 15s ping. Default 45s. */
32
+ streamIdleMs?: number;
33
+ /** How long one call keeps trying after its first failure. Default 30s. */
34
+ retryBudgetMs?: number;
35
+ /** How long a lost stream keeps trying to resume, on a cloud that resumes (Opened.resume). Default 2 minutes, as long as the cloud holds its commands. */
36
+ resumeWindowMs?: number;
37
+ /** How often a resumable stream is replaced, before the tunnel's one-hour request cap. Default 50 minutes. */
38
+ streamRefreshMs?: number;
39
+ /** The longest Retry-After a busy cloud's refused open is sent again after, once. Default 60s. */
40
+ openRetryCapMs?: number;
41
+ /** Also log slow event uploads. */
42
+ verbose?: boolean;
43
+ }
44
+ /** The session opened, then the cloud ended it with a `failed` command. `code` is the reason's leading
45
+ * code (`capacity: ...` gives capacity), when it starts with one. */
46
+ export declare class CloudEnded extends Error {
47
+ readonly code?: string;
48
+ constructor(error: string);
49
+ }
50
+ /** The tunnel, the stream, or the connection failed after the session opened. `runs` are the ones already received. The CLI prints them and exits 2. */
51
+ export declare class SessionStopped extends Error {
52
+ readonly runs: RunSummary[];
53
+ readonly dashboard: string;
54
+ constructor(reason: string, runs: RunSummary[], dashboard: string);
55
+ }
56
+ /** What runInCloud answers. When the cloud lost the session and a second one played the runs it had not finished, `runs` holds both sessions' runs and `lost` names the first. */
57
+ export type CloudSummary = SessionSummary & {
58
+ lost?: {
59
+ sessionId: string;
60
+ dashboard: string;
61
+ };
62
+ };
63
+ /** A POST that sat until its own deadline. It fails that one call. Only a cloud that stores keys sends it again. The session abort is not one of these. */
64
+ export declare class TimeoutError extends Error {
65
+ constructor();
66
+ }
67
+ /** The stream stopped carrying bytes: the idle watch fired, or the cloud closed it before finished. */
68
+ export declare class StreamLost extends Error {
69
+ constructor(message: string, options?: ErrorOptions);
70
+ }
71
+ /** How long one call keeps trying after its first failure. The first try's own wait does not count, so a timed-out try is still sent again. */
72
+ export declare const RETRY_BUDGET_MS = 30000;
73
+ /** The cloud abandons one model attempt at 90s and tries a timeout once more, then this POST has its 30s. */
74
+ export declare const CLOUD_MODEL_BUDGET_MS: number;
75
+ /** How long a tool call may take: the longest latency its suite file declares, plus {@link CLOUD_MODEL_BUDGET_MS} (210s).
76
+ * A tool with no file gets the simulator's own cap (60s) plus that 210s.
77
+ *
78
+ * The cloud asks its model before the declared latency, and the model's own time counts toward it.
79
+ * 210s is two 90s attempts plus the 30s POST budget, so a stuck model can finish before this POST gives up.
80
+ * When it runs out, the agent sees an error while the cloud may still record the call in the world log once the model returns. */
81
+ export declare function toolTimeoutMs(files: SuiteFile[], tool: string, budgetMs?: number): number;
82
+ /** The base budget plus 1s per 100KB, so a 5MB event batch or file upload is not cut off at 30s. */
83
+ export declare function postBudgetMs(baseMs: number, bytes: number): number;
84
+ /** What the cloud plays: a Flow Framework Agent's channels, messages in and reactions. */
85
+ export type AgentUnderTest = Pick<Agent, "channels" | "receive" | "reacted"> & Partial<Pick<Agent, "hasProfile">>;
86
+ export interface CloudAccess {
87
+ /** The cloud's front door, as given to --cloud. */
88
+ cloud: string;
89
+ /** The agent's CI key (FLOW_FRAMEWORK_CLOUD_KEY). */
90
+ ciKey?: string;
91
+ /** Whoever runs the tests attests that the test files hold no real people's data. */
92
+ synthetic: boolean;
93
+ agentVersion?: string;
94
+ ref?: string;
95
+ environment?: string;
96
+ }
97
+ /** The open's headers. A cloud off this machine needs the CI key and the synthetic attestation;
98
+ * a local one needs neither, and gets them when they are given. */
99
+ export declare function cloudHeaders(access: CloudAccess): Record<string, string>;
100
+ /** Where the session is played: Opened.tunnel when the cloud answers one, else the open's own address. */
101
+ export declare function tunnelBase(cloud: string, opened: Pick<Opened, "tunnel">): string;
102
+ /** Plays the suite in the cloud. If the cloud loses the session (session_gone, on a cloud whose open said
103
+ * reopen), one new session plays only the runs that have no result yet, and the two reports are merged. */
104
+ export declare function runInCloud(options: ConnectOptions): Promise<CloudSummary>;
105
+ /** The cloud answered a call with a status that is not 2xx. `code` is a JSON `error` string (the tunnel's
106
+ * refusals, which retries go by); `type` is a JSON `error` object's type (a hosted cloud's front door). */
107
+ export declare class PostError extends Error {
108
+ readonly status: number;
109
+ readonly code?: string;
110
+ readonly type?: string;
111
+ readonly retryAfterMs?: number;
112
+ constructor(url: string, status: number, text: string, retryAfterMs?: number);
113
+ }
114
+ /** The tunnel, the stream, or the connection, as opposed to a refusal the cloud wrote as JSON. */
115
+ export declare function isTransportFailure(error: unknown): boolean;