loopengine 0.1.54 → 0.1.56

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.
@@ -0,0 +1,2 @@
1
+ import type { SignRequest } from './types.js';
2
+ export declare function signGcsUrl(req: SignRequest): Promise<string>;
@@ -0,0 +1,43 @@
1
+ // Extracted straight out of adapters/http.ts's own original
2
+ // handleGcsRedirect, unchanged apart from returning the signed URL
3
+ // instead of writing the HTTP response itself — see index.ts's own doc
4
+ // comment for why signing lives here, one file per provider, instead of
5
+ // inline in the route handler.
6
+ export async function signGcsUrl(req) {
7
+ // Imported by a variable, not a string literal, so tsc treats this as
8
+ // Promise<any> instead of trying to resolve @google-cloud/storage's
9
+ // own types at compile time — installing it is only required at
10
+ // runtime for a deployment that actually uses this provider, not
11
+ // every loopengine install.
12
+ const gcsModuleName = '@google-cloud/storage';
13
+ let gcs;
14
+ try {
15
+ gcs = await import(gcsModuleName);
16
+ }
17
+ catch {
18
+ throw new Error('requires the @google-cloud/storage package — npm install @google-cloud/storage in your own project.');
19
+ }
20
+ let client;
21
+ const credentialsJson = process.env.GOOGLE_APPLICATION_CREDENTIALS_JSON;
22
+ if (credentialsJson) {
23
+ let credentials;
24
+ try {
25
+ credentials = JSON.parse(credentialsJson);
26
+ }
27
+ catch {
28
+ throw new Error('GOOGLE_APPLICATION_CREDENTIALS_JSON is not valid JSON — paste the entire contents of the downloaded service-account key file, unedited.');
29
+ }
30
+ client = new gcs.Storage({ credentials, projectId: credentials.project_id });
31
+ }
32
+ else {
33
+ client = new gcs.Storage();
34
+ }
35
+ const file = client.bucket(req.bucket).file(req.object);
36
+ const expires = Date.now() + 5 * 60 * 1000;
37
+ const signOptions = { action: 'read', expires };
38
+ if (req.disposition === 'attachment') {
39
+ signOptions.responseDisposition = `attachment; filename="${req.filename || req.object.split('/').pop()}"`;
40
+ }
41
+ const [signedUrl] = await file.getSignedUrl(signOptions);
42
+ return signedUrl;
43
+ }
@@ -0,0 +1,2 @@
1
+ import type { StorageSigner } from './types.js';
2
+ export declare const storageSigners: Record<string, StorageSigner>;
@@ -0,0 +1,4 @@
1
+ import { signGcsUrl } from './gcs.js';
2
+ export const storageSigners = {
3
+ gcs: signGcsUrl,
4
+ };
@@ -0,0 +1,7 @@
1
+ export interface SignRequest {
2
+ bucket: string;
3
+ object: string;
4
+ disposition?: 'inline' | 'attachment';
5
+ filename?: string;
6
+ }
7
+ export type StorageSigner = (req: SignRequest) => Promise<string>;
@@ -0,0 +1 @@
1
+ export {};
package/dist/index.d.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  export { runAgent } from '#core/run-agent.js';
2
+ export { storageSigners } from '#core/storage-signers/index.js';
3
+ export type { SignRequest, StorageSigner } from '#core/storage-signers/types.js';
2
4
  export type { Message, ModelCall, ModelContentBlock, ModelResponse, RunAgentOptions, RunAgentResult, } from '#core/run-agent.js';
3
5
  export type { AgentConfig, AgentModelConfig, ToolSchema, ToolDefinition } from '#core/agent-config.js';
4
6
  export type * from './core/loop-events.js';
package/dist/index.js CHANGED
@@ -4,6 +4,7 @@
4
4
  // built on top of this surface, not part of it — see the README section
5
5
  // "Using loopengine as a library" for the boundary and why.
6
6
  export { runAgent } from '#core/run-agent.js';
7
+ export { storageSigners } from '#core/storage-signers/index.js';
7
8
  // The framework-agnostic browser client for adapters/http.ts's own wire
8
9
  // protocol (see client.ts's own header comment) — this, not a deep
9
10
  // subpath import, is how a consumer's React/Vue/etc. chat UI is meant to
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "loopengine",
3
- "version": "0.1.54",
3
+ "version": "0.1.56",
4
4
  "type": "module",
5
5
  "description": "Runtime for tool-using AI agents with a transparent ReAct loop.",
6
6
  "license": "MIT",
@@ -29,6 +29,7 @@
29
29
  "dist/core/run-agent.d.ts",
30
30
  "dist/core/known-urls.js",
31
31
  "dist/core/known-urls.d.ts",
32
+ "dist/core/storage-signers",
32
33
  "dist/core/loop-events.js",
33
34
  "dist/core/loop-events.d.ts",
34
35
  "dist/core/client.js",