@re-cinq/floor-pipeline 0.1.1 → 0.1.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.
package/dist/cli.js CHANGED
File without changes
package/dist/floor.d.ts CHANGED
@@ -1,12 +1,9 @@
1
+ import { type Asking } from "@re-cinq/floor-client";
1
2
  export interface Floor {
2
3
  url: string;
3
4
  token: string;
4
5
  }
5
- export interface Asking {
6
- method: "GET" | "POST" | "PUT" | "DELETE";
7
- path: string;
8
- body?: unknown;
9
- }
6
+ export type { Asking };
10
7
  /** Null for what the floor does not have. Anything else it refuses is thrown, in the floor's own words. */
11
8
  export declare function asked<Answer>(floor: Floor, asking: Asking): Promise<Answer | null>;
12
9
  export declare function blobStored(floor: Floor, bytes: Buffer): Promise<string>;
package/dist/floor.js CHANGED
@@ -1,34 +1,26 @@
1
- // The floor, as this tool reaches it: over HTTP, as a service, through the routes anything else would use.
2
- const REQUEST_TIMEOUT_MS = 30_000;
1
+ // The floor, as this tool reaches it: the shared client, under the names this tool's own callers already use.
2
+ import { asked as askedOfFloor, createFloorClient, reach, serviceToken } from "@re-cinq/floor-client";
3
3
  const HTTP_NOT_FOUND = 404;
4
4
  /** Null for what the floor does not have. Anything else it refuses is thrown, in the floor's own words. */
5
5
  export async function asked(floor, asking) {
6
- const response = await sent(floor, asking, asking.body === undefined ? undefined : { type: "application/json", bytes: JSON.stringify(asking.body) });
7
- if (response.status === HTTP_NOT_FOUND)
8
- return null;
9
- const answer = await response.text();
10
- return answer ? JSON.parse(answer) : null;
6
+ return askedOfFloor(reachable(floor), asking, [HTTP_NOT_FOUND]);
11
7
  }
12
8
  export async function blobStored(floor, bytes) {
13
- const response = await sent(floor, { method: "POST", path: "/blobs" }, { type: "application/octet-stream", bytes: new Uint8Array(bytes) });
14
- const stored = (await response.json());
9
+ const stored = await askedOfFloor(reachable(floor), { method: "POST", path: "/blobs", bytes: { content: new Uint8Array(bytes), contentType: "application/octet-stream" } });
15
10
  return stored.hash;
16
11
  }
12
+ // A line names its files by hash, so a hash the floor does not hold is a pipeline that cannot be read, not an absence to carry on past.
17
13
  export async function blobRead(floor, hash) {
18
- const response = await sent(floor, { method: "GET", path: `/blobs/${hash}` });
19
- if (response.status === HTTP_NOT_FOUND)
14
+ const { blobs } = clientFor(floor);
15
+ const stored = await blobs.get(hash);
16
+ if (!stored)
20
17
  throw new Error(`the floor has no blob "${hash}", which a line names as its file`);
21
- return Buffer.from(await response.arrayBuffer());
18
+ return Buffer.from(stored.bytes);
22
19
  }
23
- async function sent(floor, asking, body) {
24
- const response = await fetch(`${floor.url}${asking.path}`, {
25
- method: asking.method,
26
- headers: { authorization: `Bearer ${floor.token}`, ...(body && { "content-type": body.type }) },
27
- body: body?.bytes,
28
- signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS),
29
- });
30
- if (response.ok || response.status === HTTP_NOT_FOUND)
31
- return response;
32
- throw new Error(`the floor refused ${asking.method} ${asking.path} with ${response.status}: ${await response.text()}`);
20
+ function reachable(floor) {
21
+ return reach(floor.url, serviceToken(floor.token));
22
+ }
23
+ function clientFor(floor) {
24
+ return createFloorClient({ url: floor.url, token: serviceToken(floor.token) });
33
25
  }
34
26
  //# sourceMappingURL=floor.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@re-cinq/floor-pipeline",
3
- "version": "0.1.1",
3
+ "version": "0.1.4",
4
4
  "description": "A floor's pipeline as one YAML file: an assembly line with its stations, its agent definitions and their prompts, its files and its schedules. Exports one from a floor, imports one into a floor, and applies a folder of them in order, each once. It speaks the floor's HTTP API and nothing else.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -49,6 +49,7 @@
49
49
  "typecheck": "tsc --noEmit"
50
50
  },
51
51
  "dependencies": {
52
+ "@re-cinq/floor-client": "0.1.4",
52
53
  "yaml": "^2.7.0",
53
54
  "zod": "^4.5.4"
54
55
  },