@agentapps/station 0.0.0-stage → 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 (75) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +58 -2
  3. package/dist/api-key-store.d.ts +46 -0
  4. package/dist/api-key-store.d.ts.map +1 -0
  5. package/dist/api-key-store.js +84 -0
  6. package/dist/api-key-store.js.map +1 -0
  7. package/dist/app-station.d.ts +129 -0
  8. package/dist/app-station.d.ts.map +1 -0
  9. package/dist/app-station.js +706 -0
  10. package/dist/app-station.js.map +1 -0
  11. package/dist/approval-manager.d.ts +75 -0
  12. package/dist/approval-manager.d.ts.map +1 -0
  13. package/dist/approval-manager.js +96 -0
  14. package/dist/approval-manager.js.map +1 -0
  15. package/dist/document-store.d.ts +86 -0
  16. package/dist/document-store.d.ts.map +1 -0
  17. package/dist/document-store.js +230 -0
  18. package/dist/document-store.js.map +1 -0
  19. package/dist/file-handlers/object-store.d.ts +113 -0
  20. package/dist/file-handlers/object-store.d.ts.map +1 -0
  21. package/dist/file-handlers/object-store.js +273 -0
  22. package/dist/file-handlers/object-store.js.map +1 -0
  23. package/dist/file-handlers/signed-url.d.ts +44 -0
  24. package/dist/file-handlers/signed-url.d.ts.map +1 -0
  25. package/dist/file-handlers/signed-url.js +68 -0
  26. package/dist/file-handlers/signed-url.js.map +1 -0
  27. package/dist/file-handlers/volume-handlers.d.ts +136 -0
  28. package/dist/file-handlers/volume-handlers.d.ts.map +1 -0
  29. package/dist/file-handlers/volume-handlers.js +426 -0
  30. package/dist/file-handlers/volume-handlers.js.map +1 -0
  31. package/dist/in-process-runtime.d.ts +49 -0
  32. package/dist/in-process-runtime.d.ts.map +1 -0
  33. package/dist/in-process-runtime.js +50 -0
  34. package/dist/in-process-runtime.js.map +1 -0
  35. package/dist/index.d.ts +27 -0
  36. package/dist/index.d.ts.map +1 -0
  37. package/dist/index.js +34 -0
  38. package/dist/index.js.map +1 -0
  39. package/dist/local-process-runtime.d.ts +28 -0
  40. package/dist/local-process-runtime.d.ts.map +1 -0
  41. package/dist/local-process-runtime.js +134 -0
  42. package/dist/local-process-runtime.js.map +1 -0
  43. package/dist/oauth-manager.d.ts +90 -0
  44. package/dist/oauth-manager.d.ts.map +1 -0
  45. package/dist/oauth-manager.js +148 -0
  46. package/dist/oauth-manager.js.map +1 -0
  47. package/dist/oauth-pages.d.ts +9 -0
  48. package/dist/oauth-pages.d.ts.map +1 -0
  49. package/dist/oauth-pages.js +59 -0
  50. package/dist/oauth-pages.js.map +1 -0
  51. package/dist/permission-enforcer.d.ts +52 -0
  52. package/dist/permission-enforcer.d.ts.map +1 -0
  53. package/dist/permission-enforcer.js +144 -0
  54. package/dist/permission-enforcer.js.map +1 -0
  55. package/dist/policy-store.d.ts +34 -0
  56. package/dist/policy-store.d.ts.map +1 -0
  57. package/dist/policy-store.js +35 -0
  58. package/dist/policy-store.js.map +1 -0
  59. package/dist/secrets-manager.d.ts +32 -0
  60. package/dist/secrets-manager.d.ts.map +1 -0
  61. package/dist/secrets-manager.js +12 -0
  62. package/dist/secrets-manager.js.map +1 -0
  63. package/dist/server.d.ts +368 -0
  64. package/dist/server.d.ts.map +1 -0
  65. package/dist/server.js +1954 -0
  66. package/dist/server.js.map +1 -0
  67. package/dist/telemetry.d.ts +9 -0
  68. package/dist/telemetry.d.ts.map +1 -0
  69. package/dist/telemetry.js +9 -0
  70. package/dist/telemetry.js.map +1 -0
  71. package/dist/types.d.ts +47 -0
  72. package/dist/types.d.ts.map +1 -0
  73. package/dist/types.js +9 -0
  74. package/dist/types.js.map +1 -0
  75. package/package.json +40 -3
@@ -0,0 +1,144 @@
1
+ /**
2
+ * Policy evaluation: which effect a Principal's Policy gives a tool call.
3
+ *
4
+ * A Policy is a list of Rules plus a default effect (POLICY-REQ-2). The most
5
+ * specific matching Rule wins, ordered app+tool+when > app+tool > app+* >
6
+ * *+*; among equal specificity the first declared wins; no match means the
7
+ * default effect (POLICY-REQ-3). Annotations never decide on their own: the
8
+ * "sensitive or destructive tools ask" behaviour is two default Rules every
9
+ * new Policy starts with (POLICY-REQ-4).
10
+ */
11
+ import { ADMIN_PRINCIPAL_ID, } from '@agentapps/protocol';
12
+ /**
13
+ * The Policy every new Principal starts with (POLICY-REQ-2, POLICY-REQ-4):
14
+ * allow by default, ask for destructive and for sensitive tools.
15
+ *
16
+ * @spec POLICY-REQ-4
17
+ */
18
+ export function defaultPolicy(principalId, now = new Date().toISOString()) {
19
+ return {
20
+ principalId,
21
+ approver: ADMIN_PRINCIPAL_ID,
22
+ defaultEffect: 'allow',
23
+ rules: [
24
+ {
25
+ id: 'default-destructive',
26
+ app: '*',
27
+ tool: '*',
28
+ effect: 'ask',
29
+ when: { annotation: 'destructiveHint' },
30
+ },
31
+ {
32
+ id: 'default-sensitive',
33
+ app: '*',
34
+ tool: '*',
35
+ effect: 'ask',
36
+ when: { annotation: 'sensitive' },
37
+ },
38
+ ],
39
+ createdAt: now,
40
+ updatedAt: now,
41
+ };
42
+ }
43
+ /**
44
+ * Evaluate a Policy for one tool call.
45
+ *
46
+ * @spec POLICY-REQ-3
47
+ */
48
+ export function evaluatePolicy(policy, call) {
49
+ let best = null;
50
+ for (const rule of policy.rules) {
51
+ if (rule.app !== '*' && rule.app !== call.app)
52
+ continue;
53
+ if (rule.tool !== '*' && rule.tool !== call.tool)
54
+ continue;
55
+ if (rule.when && !conditionHolds(rule.when, call))
56
+ continue;
57
+ const score = specificity(rule);
58
+ // Strictly greater: among equal specificity the first declared wins.
59
+ if (!best || score > best.score)
60
+ best = { rule, score };
61
+ }
62
+ return best
63
+ ? { effect: best.rule.effect, rule: best.rule.id }
64
+ : { effect: policy.defaultEffect, rule: 'default' };
65
+ }
66
+ /** app+tool+when (3) > app+tool (2) > app+* (1) > *+* (0). */
67
+ function specificity(rule) {
68
+ const app = rule.app !== '*';
69
+ const tool = rule.tool !== '*';
70
+ if (app && tool)
71
+ return rule.when ? 3 : 2;
72
+ if (app)
73
+ return 1;
74
+ return 0;
75
+ }
76
+ function conditionHolds(when, call) {
77
+ if ('annotation' in when && typeof when.annotation === 'string') {
78
+ return call.annotations?.[when.annotation] === true;
79
+ }
80
+ for (const [arg, matcher] of Object.entries(when)) {
81
+ if (!matches(matcher, call.args[arg], arg in call.args))
82
+ return false;
83
+ }
84
+ return true;
85
+ }
86
+ /** A missing argument never matches a positive condition (POLICY-REQ-3). */
87
+ function matches(m, value, present) {
88
+ if (m.not)
89
+ return !matches(m.not, value, present);
90
+ if (!present)
91
+ return false;
92
+ if ('equals' in m && m.equals !== undefined && value !== m.equals)
93
+ return false;
94
+ if (m.startsWith !== undefined && !(typeof value === 'string' && value.startsWith(m.startsWith)))
95
+ return false;
96
+ if (m.endsWith !== undefined && !(typeof value === 'string' && value.endsWith(m.endsWith)))
97
+ return false;
98
+ if (m.matches !== undefined && !(typeof value === 'string' && globMatch(m.matches, value)))
99
+ return false;
100
+ if (m.in !== undefined && !m.in.includes(value))
101
+ return false;
102
+ return true;
103
+ }
104
+ function globMatch(glob, value) {
105
+ const re = new RegExp(`^${glob.split('*').map(escapeRegExp).join('.*')}$`);
106
+ return re.test(value);
107
+ }
108
+ function escapeRegExp(s) {
109
+ return s.replace(/[.+?^${}()|[\]\\]/g, '\\$&');
110
+ }
111
+ /** A Rule whose `when` reads the call's arguments, unknown when listing. */
112
+ function dependsOnArgs(rule) {
113
+ return !!rule.when && !('annotation' in rule.when);
114
+ }
115
+ /**
116
+ * Whether a tool stays in a Principal's tool list: hidden only when the Policy
117
+ * denies it whatever the arguments.
118
+ *
119
+ * @spec POLICY-REQ-11
120
+ */
121
+ export function toolVisible(policy, app, tool, annotations) {
122
+ const known = { ...policy, rules: policy.rules.filter((r) => !dependsOnArgs(r)) };
123
+ if (evaluatePolicy(known, { app, tool, args: {}, annotations }).effect !== 'deny')
124
+ return true;
125
+ return policy.rules.some((r) => dependsOnArgs(r) &&
126
+ (r.app === '*' || r.app === app) &&
127
+ (r.tool === '*' || r.tool === tool) &&
128
+ r.effect !== 'deny');
129
+ }
130
+ /**
131
+ * Whether an Installation of `app` is listed to a Principal: hidden only when
132
+ * the Policy denies the App as a whole.
133
+ *
134
+ * @spec POLICY-REQ-10
135
+ */
136
+ export function appVisible(policy, app) {
137
+ const known = { ...policy, rules: policy.rules.filter((r) => !dependsOnArgs(r) && !r.when) };
138
+ // A tool name no Rule can name stands for "any tool of this App".
139
+ const anyTool = '\u0000';
140
+ if (evaluatePolicy(known, { app, tool: anyTool, args: {} }).effect !== 'deny')
141
+ return true;
142
+ return policy.rules.some((r) => r.app === app && r.tool !== '*' && r.effect !== 'deny');
143
+ }
144
+ //# sourceMappingURL=permission-enforcer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"permission-enforcer.js","sourceRoot":"","sources":["../src/permission-enforcer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EACL,kBAAkB,GAMnB,MAAM,qBAAqB,CAAC;AAiB7B;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAAC,WAAmB,EAAE,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;IAC/E,OAAO;QACL,WAAW;QACX,QAAQ,EAAE,kBAAkB;QAC5B,aAAa,EAAE,OAAO;QACtB,KAAK,EAAE;YACL;gBACE,EAAE,EAAE,qBAAqB;gBACzB,GAAG,EAAE,GAAG;gBACR,IAAI,EAAE,GAAG;gBACT,MAAM,EAAE,KAAK;gBACb,IAAI,EAAE,EAAE,UAAU,EAAE,iBAAiB,EAAE;aACxC;YACD;gBACE,EAAE,EAAE,mBAAmB;gBACvB,GAAG,EAAE,GAAG;gBACR,IAAI,EAAE,GAAG;gBACT,MAAM,EAAE,KAAK;gBACb,IAAI,EAAE,EAAE,UAAU,EAAE,WAAW,EAAE;aAClC;SACF;QACD,SAAS,EAAE,GAAG;QACd,SAAS,EAAE,GAAG;KACf,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,MA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KAAK,MAAM;QAAE,OAAO,IAAI,CAAC;IAC/F,OAAO,MAAM,CAAC,KAAK,CAAC,IAAI,CACtB,CAAC,CAAC,EAAE,EAAE,CACJ,aAAa,CAAC,CAAC,CAAC;QAChB,CAAC,CAAC,CAAC,GAAG,KAAK,GAAG,IAAI,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC;QAChC,CAAC,CAAC,CAAC,IAAI,KAAK,GAAG,IAAI,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC;QACnC,CAAC,CAAC,MAAM,KAAK,MAAM,CACtB,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,MAAc,EAAE,GAAW;IACpD,MAAM,KAAK,GAAG,EAAE,GAAG,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC;IAC7F,kEAAkE;IAClE,MAAM,OAAO,GAAG,QAAQ,CAAC;IACzB,IAAI,cAAc,CAAC,KAAK,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC,MAAM,KAAK,MAAM;QAAE,OAAO,IAAI,CAAC;IAC3F,OAAO,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,KAAK,GAAG,IAAI,CAAC,CAAC,IAAI,KAAK,GAAG,IAAI,CAAC,CAAC,MAAM,KAAK,MAAM,CAAC,CAAC;AAC1F,CAAC"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * PolicyStore: one Policy per Principal (POLICY-REQ-2).
3
+ */
4
+ import type { Policy } from '@agentapps/protocol';
5
+ export interface PolicyStore {
6
+ /** Create or replace the Policy of `policy.principalId`. */
7
+ put(policy: Policy): Promise<void>;
8
+ /** The Policy of a Principal, or null when none is stored. */
9
+ get(principalId: string): Promise<Policy | null>;
10
+ /** Every stored Policy. */
11
+ list(): Promise<Policy[]>;
12
+ /** Remove a Principal's Policy. Returns true if it existed. */
13
+ remove(principalId: string): Promise<boolean>;
14
+ }
15
+ /**
16
+ * The Policy that applies to a Principal: the stored one, or the default a
17
+ * new Principal starts with (POLICY-REQ-2).
18
+ *
19
+ * @spec POLICY-REQ-2
20
+ */
21
+ export declare function policyFor(store: PolicyStore, principalId: string): Promise<Policy>;
22
+ /**
23
+ * In-memory implementation (tests and embedded use).
24
+ *
25
+ * @spec POLICY-REQ-2
26
+ */
27
+ export declare class InMemoryPolicyStore implements PolicyStore {
28
+ private readonly data;
29
+ put(policy: Policy): Promise<void>;
30
+ get(principalId: string): Promise<Policy | null>;
31
+ list(): Promise<Policy[]>;
32
+ remove(principalId: string): Promise<boolean>;
33
+ }
34
+ //# sourceMappingURL=policy-store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"policy-store.d.ts","sourceRoot":"","sources":["../src/policy-store.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAGlD,MAAM,WAAW,WAAW;IAC1B,4DAA4D;IAC5D,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACnC,8DAA8D;IAC9D,GAAG,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IACjD,2BAA2B;IAC3B,IAAI,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IAC1B,+DAA+D;IAC/D,MAAM,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CAC/C;AAED;;;;;GAKG;AACH,wBAAsB,SAAS,CAAC,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAExF;AAED;;;;GAIG;AACH,qBAAa,mBAAoB,YAAW,WAAW;IACrD,OAAO,CAAC,QAAQ,CAAC,IAAI,CAA6B;IAE5C,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIlC,GAAG,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAKhD,IAAI,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAIzB,MAAM,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;CAGpD"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * PolicyStore: one Policy per Principal (POLICY-REQ-2).
3
+ */
4
+ import { defaultPolicy } from './permission-enforcer.js';
5
+ /**
6
+ * The Policy that applies to a Principal: the stored one, or the default a
7
+ * new Principal starts with (POLICY-REQ-2).
8
+ *
9
+ * @spec POLICY-REQ-2
10
+ */
11
+ export async function policyFor(store, principalId) {
12
+ return (await store.get(principalId)) ?? defaultPolicy(principalId);
13
+ }
14
+ /**
15
+ * In-memory implementation (tests and embedded use).
16
+ *
17
+ * @spec POLICY-REQ-2
18
+ */
19
+ export class InMemoryPolicyStore {
20
+ data = new Map();
21
+ async put(policy) {
22
+ this.data.set(policy.principalId, structuredClone(policy));
23
+ }
24
+ async get(principalId) {
25
+ const p = this.data.get(principalId);
26
+ return p ? structuredClone(p) : null;
27
+ }
28
+ async list() {
29
+ return [...this.data.values()].map((p) => structuredClone(p));
30
+ }
31
+ async remove(principalId) {
32
+ return this.data.delete(principalId);
33
+ }
34
+ }
35
+ //# sourceMappingURL=policy-store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"policy-store.js","sourceRoot":"","sources":["../src/policy-store.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAazD;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,KAAkB,EAAE,WAAmB;IACrE,OAAO,CAAC,MAAM,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,IAAI,aAAa,CAAC,WAAW,CAAC,CAAC;AACtE,CAAC;AAED;;;;GAIG;AACH,MAAM,OAAO,mBAAmB;IACb,IAAI,GAAG,IAAI,GAAG,EAAkB,CAAC;IAElD,KAAK,CAAC,GAAG,CAAC,MAAc;QACtB,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,WAAW,EAAE,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC;IAC7D,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,WAAmB;QAC3B,MAAM,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;QACrC,OAAO,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACvC,CAAC;IAED,KAAK,CAAC,IAAI;QACR,OAAO,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;IAChE,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,WAAmB;QAC9B,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;IACvC,CAAC;CACF"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * SecretsManager — host-side secret resolution contract.
3
+ *
4
+ * The Station never reads or persists secret payloads on its own; it
5
+ * answers instance→host secret requests through a SecretsManager supplied
6
+ * by the Host (the CLI's state, for example).
7
+ *
8
+ * Security rule: system and installation secrets are resolved through SDK
9
+ * requests, never injected as environment variables.
10
+ */
11
+ /** Context passed to SecretsManager lookups. */
12
+ export interface SecretsContext {
13
+ /** Unique installation ID (e.g. "ins_a7f3b2c1"). Primary key for all lookups. */
14
+ installationId: string;
15
+ /** Tenant scoped to the request. */
16
+ tenant: {
17
+ userId: string;
18
+ workspaceId?: string;
19
+ };
20
+ /** Session that triggered the request, when available. */
21
+ sessionId?: string;
22
+ }
23
+ /** Host-side secret store contract. */
24
+ export interface SecretsManager {
25
+ /** Resolve system-level secrets for the given installation/tenant. */
26
+ getSystemSecrets(ctx: SecretsContext): Promise<Record<string, string> | null>;
27
+ /** Resolve installation secrets for the given installation/tenant. */
28
+ getInstallationSecrets(ctx: SecretsContext): Promise<Record<string, string> | null>;
29
+ /** Persist updated installation secrets. Return true on success. */
30
+ updateInstallationSecrets?(ctx: SecretsContext, secrets: Record<string, string>): Promise<boolean>;
31
+ }
32
+ //# sourceMappingURL=secrets-manager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"secrets-manager.d.ts","sourceRoot":"","sources":["../src/secrets-manager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,gDAAgD;AAChD,MAAM,WAAW,cAAc;IAC7B,iFAAiF;IACjF,cAAc,EAAE,MAAM,CAAC;IACvB,oCAAoC;IACpC,MAAM,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACjD,0DAA0D;IAC1D,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,uCAAuC;AACvC,MAAM,WAAW,cAAc;IAC7B,sEAAsE;IACtE,gBAAgB,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC;IAE9E,sEAAsE;IACtE,sBAAsB,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC;IAEpF,oEAAoE;IACpE,yBAAyB,CAAC,CACxB,GAAG,EAAE,cAAc,EACnB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC9B,OAAO,CAAC,OAAO,CAAC,CAAC;CACrB"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * SecretsManager — host-side secret resolution contract.
3
+ *
4
+ * The Station never reads or persists secret payloads on its own; it
5
+ * answers instance→host secret requests through a SecretsManager supplied
6
+ * by the Host (the CLI's state, for example).
7
+ *
8
+ * Security rule: system and installation secrets are resolved through SDK
9
+ * requests, never injected as environment variables.
10
+ */
11
+ export {};
12
+ //# sourceMappingURL=secrets-manager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"secrets-manager.js","sourceRoot":"","sources":["../src/secrets-manager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG"}
@@ -0,0 +1,368 @@
1
+ /**
2
+ * Station Server
3
+ *
4
+ * Production HTTP server that wraps one or more AppStation instances and
5
+ * serves the Agent Apps v2.0 protocol over POST /messages.
6
+ *
7
+ * Usage:
8
+ * import { StationServer, serve } from '@agentapps/station';
9
+ *
10
+ * const server = await serve({
11
+ * port: 4100,
12
+ * apps: [{ id: 'app.hello', version: '1.0.0', factory }],
13
+ * });
14
+ */
15
+ import type { ApiKeyStore } from './api-key-store.js';
16
+ import { type DocumentStore } from './document-store.js';
17
+ import { ObjectStore } from './file-handlers/object-store.js';
18
+ import { type AppFactory } from './in-process-runtime.js';
19
+ import type { PolicyStore } from './policy-store.js';
20
+ import type { SecretsManager } from './secrets-manager.js';
21
+ /** One Installation as the Station knows it (POLICY-REQ-10). */
22
+ export interface StationInstallation {
23
+ installationId: string;
24
+ alias: string;
25
+ appId: string;
26
+ /** The Installation's Effective Permissions. */
27
+ permissions?: Record<string, unknown>;
28
+ }
29
+ export interface AppEntry {
30
+ id: string;
31
+ version: string;
32
+ factory: AppFactory;
33
+ name?: string;
34
+ description?: string;
35
+ /** Auth configuration from the app manifest (authorizeUrl, tokenUrl, scopes, provider, etc.). */
36
+ auth?: {
37
+ type?: string;
38
+ provider?: string;
39
+ authorizeUrl?: string;
40
+ tokenUrl?: string;
41
+ scopes?: string[];
42
+ systemSecrets?: string[];
43
+ installationSecrets?: string[];
44
+ };
45
+ /**
46
+ * Full app manifest (agentapp.json). When provided, the server can serve
47
+ * it via `GET /apps/:appId/manifest` and populate the launcher page.
48
+ */
49
+ manifest?: Record<string, unknown>;
50
+ /**
51
+ * Absolute path to the app's source directory. When provided, the server
52
+ * can serve static files (bundles, assets) via `GET /apps/:appId/bundles/*`.
53
+ */
54
+ sourcePath?: string;
55
+ }
56
+ export interface StationEndpoint {
57
+ /** URL of the station's announce endpoint (e.g., 'http://station:3000/api/agent-apps/announce') */
58
+ url: string;
59
+ /** Bearer token for authenticating with the station */
60
+ token?: string;
61
+ }
62
+ export interface StationServerOptions {
63
+ apps?: AppEntry[];
64
+ port?: number;
65
+ host?: string;
66
+ token?: string;
67
+ stationId?: string;
68
+ idleTimeoutMs?: number;
69
+ /**
70
+ * Public base URL of the station (e.g. "https://your-station.example.com").
71
+ *
72
+ * Used to build the OAuth redirect URI (`{publicUrl}/auth/callback`)
73
+ * for all apps — so individual apps don't need a REDIRECT_URI secret.
74
+ * If omitted, auto-detected from `http://localhost:{port}`.
75
+ */
76
+ publicUrl?: string;
77
+ /** Stations to announce to on startup. The station POSTs its app catalog so stations discover it automatically. */
78
+ stations?: StationEndpoint[];
79
+ /**
80
+ * Host-side secret store. When provided, the server answers instance→host
81
+ * secret requests (get_system_secrets / get_installation_secrets / update_installation_secrets).
82
+ * Without it, those requests are rejected immediately instead of timing out.
83
+ */
84
+ secrets?: SecretsManager;
85
+ /**
86
+ * Resolve an installationId to its appId. Required for OAuth to find the
87
+ * managed app. In CLI mode, this queries the instance registry.
88
+ */
89
+ resolveInstallation?: (installationId: string) => {
90
+ appId: string;
91
+ } | undefined;
92
+ /**
93
+ * The workspace's Installations, read on every request so changes apply
94
+ * without a restart. Gateways discover them through `GET /installations`
95
+ * and open sessions as them (POLICY-REQ-10).
96
+ */
97
+ installations?: () => StationInstallation[];
98
+ /** API key store. When provided, enables multi-key authentication. */
99
+ apiKeys?: ApiKeyStore;
100
+ /** Policy store, one Policy per Principal. When provided, tool calls are evaluated (POLICY-REQ-5). */
101
+ policies?: PolicyStore;
102
+ /** Enable management API endpoints (/api/keys). Default: false. */
103
+ enableManagementApi?: boolean;
104
+ /** Timeout for parked `ask` calls in milliseconds. Default: 5 minutes (POLICY-REQ-6). */
105
+ askTimeoutMs?: number;
106
+ /**
107
+ * Local admin credential: a bearer token that authenticates as the `admin`
108
+ * Principal, so the CLI that launched this station can answer approvals
109
+ * (POLICY-REQ-7) without an API key.
110
+ */
111
+ adminToken?: string;
112
+ /**
113
+ * Extra `POST` routes answered for the `admin` Principal only, such as the
114
+ * CLI's Claude Code hook adapter (HOOK-REQ-26). The handler gets the parsed
115
+ * JSON body and returns the JSON answer.
116
+ */
117
+ adminRoutes?: Record<string, (body: unknown) => Promise<unknown>>;
118
+ /**
119
+ * Base path for volume storage. Each installation gets a physical
120
+ * directory under `{volumesBasePath}/ws_{workspaceId}/inst_{installationId}/workspace/`.
121
+ * Defaults to `~/.agentapps/data` or the `AGENTAPPS_VOLUMES_BASE_PATH` env var.
122
+ */
123
+ volumesBasePath?: string;
124
+ /**
125
+ * Object store override. When omitted the server builds one on
126
+ * `volumesBasePath`, its secret and its public URL once it starts.
127
+ */
128
+ objectStore?: ObjectStore;
129
+ /**
130
+ * Where Installations' Storage lives. Defaults to process memory; the CLI's
131
+ * `serve` passes the workspace's on-disk store so it shares data with the
132
+ * CLI (CLI-REQ-3).
133
+ */
134
+ documentStore?: DocumentStore;
135
+ }
136
+ export interface ServerInfo {
137
+ port: number;
138
+ host: string;
139
+ url: string;
140
+ stationId: string;
141
+ apps: string[];
142
+ /** OAuth callback URI used for all apps. */
143
+ oauthCallbackUrl: string;
144
+ }
145
+ export declare class StationServer {
146
+ private managedApps;
147
+ private sessionIndex;
148
+ /** Parked calls per Session (POLICY-REQ-13). */
149
+ private readonly parkedCalls;
150
+ /** `session_close` messages held back until their Session's parked calls end (POLICY-REQ-13). */
151
+ private readonly heldCloses;
152
+ private httpServer;
153
+ private _info;
154
+ private readonly stationId;
155
+ private readonly token?;
156
+ private readonly idleTimeoutMs;
157
+ private readonly defaultPort;
158
+ private readonly defaultHost;
159
+ private readonly stations;
160
+ private readonly secrets?;
161
+ private readonly documentStore;
162
+ private readonly resolveInstallation?;
163
+ private readonly installations?;
164
+ private readonly oauth;
165
+ private readonly publicUrl?;
166
+ private readonly apiKeyStore?;
167
+ private readonly policyStore?;
168
+ private readonly approvalManager?;
169
+ private readonly adminToken?;
170
+ private readonly adminRoutes;
171
+ private readonly enableManagementApi;
172
+ private readonly volumesBasePath;
173
+ private readonly stationSecret;
174
+ /** Objects: immutable blobs per Installation, served at GET /objects/{id}. */
175
+ private objectStore;
176
+ /** Installation and Workspace of each open session, for scoping object Requests. */
177
+ private readonly sessionScopes;
178
+ /** Cached tool definitions per app for annotation lookups. */
179
+ private readonly toolsCache;
180
+ constructor(options?: StationServerOptions);
181
+ addApp(entry: AppEntry): void;
182
+ removeApp(appId: string): Promise<void>;
183
+ start(port?: number, host?: string): Promise<ServerInfo>;
184
+ stop(): Promise<void>;
185
+ get info(): ServerInfo | null;
186
+ get appIds(): string[];
187
+ private sendAndWait;
188
+ /**
189
+ * Relay a `session_close`. A Session with parked calls is answered
190
+ * `session_closed` at once and ends after its last parked call.
191
+ *
192
+ * @spec POLICY-REQ-13
193
+ */
194
+ private closeSession;
195
+ /** A call parked on `sessionId` (POLICY-REQ-13). */
196
+ private holdSession;
197
+ /** A parked call on `sessionId` was decided and answered: end the Session if a close was held. */
198
+ private releaseSession;
199
+ private autoInitialize;
200
+ /**
201
+ * Answer an instance→host secret request using the configured SecretsManager.
202
+ *
203
+ * Replies mirror the AgentAppHost wire format: `system_secrets` /
204
+ * `installation_secrets` / `update_installation_secrets_response` on success, and a
205
+ * `prompt_result` with `success: false` on failure — so the app's
206
+ * `ctx.systemSecret()` / `ctx.installationSecret()` resolve instead of timing out.
207
+ */
208
+ private handleSecretsCallback;
209
+ private findInstallation;
210
+ /**
211
+ * `GET /installations`: the Installations the caller's Principal may use.
212
+ * Needs a credential even when the Station is otherwise open.
213
+ *
214
+ * @spec POLICY-REQ-10
215
+ * @spec POLICY-REQ-12
216
+ */
217
+ private handleInstallations;
218
+ /** The Principal a request's bearer credential names, checked even on an open Station. */
219
+ private identifyCredential;
220
+ private resolveApp;
221
+ /**
222
+ * Answer an instance→host Storage request with the configured document
223
+ * store (in memory by default), scoped by installationId.
224
+ */
225
+ private handleStorageCallback;
226
+ /**
227
+ * Answer an instance→host volume storage request.
228
+ *
229
+ * Resolves the workspaceId + installationId from the message (or falls
230
+ * back to the managed app's id), then delegates to the volume handlers
231
+ * which operate on the physical `workspace/` directory.
232
+ */
233
+ private handleVolumeRequest;
234
+ /** The object store, built lazily once the server knows its URL. */
235
+ private objects;
236
+ /**
237
+ * Answer an instance→host object Request. The Installation and Workspace
238
+ * come from the session that was opened over `/messages`; a session the
239
+ * server did not open itself falls back to the app id and `default`.
240
+ */
241
+ private handleObjectCallback;
242
+ /**
243
+ * Announce all apps to registered stations.
244
+ *
245
+ * Opens a temporary session per app to discover its tools, then POSTs
246
+ * the catalog to each station's announce endpoint. Stations use this
247
+ * to register the app station and its apps automatically.
248
+ */
249
+ announceToStations(): Promise<void>;
250
+ private buildAnnounceCatalog;
251
+ private postAnnounce;
252
+ private handleRequest;
253
+ /**
254
+ * Resolve the OAuth redirect URI for the app station.
255
+ *
256
+ * Priority: explicit `publicUrl` option → auto-detect from request headers
257
+ * (supports X-Forwarded-Proto/Host behind a reverse proxy) → fallback to
258
+ * the server's own info.
259
+ */
260
+ private getOAuthRedirectUri;
261
+ /**
262
+ * GET /auth/start?installationId=X[&userId=Z&workspaceId=W]
263
+ *
264
+ * Initiates an OAuth flow. Resolves the installationId to an appId, reads
265
+ * the app's auth config and system secrets, builds the authorize URL, and
266
+ * either redirects the browser (302) or returns JSON with the URL.
267
+ */
268
+ private handleAuthStart;
269
+ /**
270
+ * GET /auth/callback?code=X&state=Y
271
+ *
272
+ * Receives the OAuth provider's redirect. Exchanges the code for tokens,
273
+ * persists them via the SecretsManager, and shows a success/error page.
274
+ */
275
+ private handleAuthCallback;
276
+ /**
277
+ * GET /auth/status?installationId=X
278
+ *
279
+ * Returns the current authentication status for an installation.
280
+ * Used by the CLI to poll for completion after delegating OAuth
281
+ * to the station via /auth/start.
282
+ */
283
+ private handleAuthStatus;
284
+ private handleMessages;
285
+ /**
286
+ * Authenticate an incoming request.
287
+ *
288
+ * Returns:
289
+ * - `null` when no auth is configured (pass-through)
290
+ * - `false` when auth is required but the request is invalid
291
+ * - `{ identity, policyId }` on success
292
+ */
293
+ private authenticateRequest;
294
+ /** Look up cached tool annotations for permission enforcement. */
295
+ private getToolAnnotations;
296
+ /** Populate tool cache for an app (called after auto-init or announce). */
297
+ private cacheTools;
298
+ /**
299
+ * GET /apps — JSON catalog of all registered apps.
300
+ *
301
+ * Returns a lightweight listing (id, version, name, description) suitable
302
+ * for registries and launchers to discover what's running on this station.
303
+ */
304
+ private handleAppCatalog;
305
+ /**
306
+ * GET /apps/:appId/manifest — full manifest JSON for an app.
307
+ *
308
+ * Serves the `agentapp.json` content (or the manifest passed via `AppEntry.manifest`).
309
+ * Returns 404 if the app is not registered, and 404 with a helpful message
310
+ * if the app was registered without a manifest.
311
+ */
312
+ private handleAppManifest;
313
+ /**
314
+ * GET /launcher — generic HTML launcher page.
315
+ *
316
+ * Renders an HTML page that reads each app's manifest, evaluates screen
317
+ * conditions, and auto-opens the first eligible screen in an iframe.
318
+ *
319
+ * The page embeds manifest data as JSON so client-side JS can:
320
+ * - Evaluate `condition` predicates on screens (e.g. 'authenticated', '!authenticated')
321
+ * - Show/hide screens based on the current auth state
322
+ * - Auto-open the first visible launcher screen
323
+ * - Navigate between screens without a full page reload
324
+ *
325
+ * Screens without a `bundleUrl` are listed but not openable in the iframe.
326
+ */
327
+ private handleLauncher;
328
+ /**
329
+ * GET /apps/:appId/bundles/* — serve static files from the app's source directory.
330
+ *
331
+ * The path after `/bundles/` is resolved relative to the app's `sourcePath`.
332
+ * Path traversal is prevented by normalizing and checking the resolved path
333
+ * stays within the source directory.
334
+ */
335
+ private handleStaticBundle;
336
+ /**
337
+ * GET /objects/{id}[?token=…]
338
+ *
339
+ * - Public object → 200, permanent.
340
+ * - Private object with a valid signed link token for that id → 200.
341
+ * - Private object without a valid token → 401.
342
+ * - Unknown id → 404.
343
+ * Cache-Control: no-cache, so an expired link is not served from a cache.
344
+ */
345
+ private handleObjectRequest;
346
+ /**
347
+ * Resolve a relative path against a base directory, ensuring the result
348
+ * stays within the base. Returns null if the path escapes the base.
349
+ */
350
+ private resolveSafePath;
351
+ /**
352
+ * Determine the base URL for building absolute links in the launcher.
353
+ * Uses `publicUrl` if configured, otherwise falls back to request headers.
354
+ */
355
+ private getBaseUrl;
356
+ /**
357
+ * Pending Approvals for the Approver (POLICY-REQ-7): `GET /approvals` lists
358
+ * them and `POST /approvals/{id}` with `{ decision: 'approve' | 'deny' }`
359
+ * decides one. Only the `admin` Principal may answer; an open station has
360
+ * no other caller.
361
+ *
362
+ * @spec POLICY-REQ-7
363
+ */
364
+ private handleApprovals;
365
+ private handleManagementApi;
366
+ }
367
+ export declare function serve(options: StationServerOptions): Promise<StationServer>;
368
+ //# sourceMappingURL=server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAiBH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAItD,OAAO,EACL,KAAK,aAAa,EAGnB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAuB,WAAW,EAAE,MAAM,iCAAiC,CAAC;AASnF,OAAO,EAAE,KAAK,UAAU,EAAoB,MAAM,yBAAyB,CAAC;AAI5E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,s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