@praveen-palanisamy/agent-browser-runtime 0.1.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.
- package/CHANGELOG.md +23 -0
- package/LICENSE +23 -0
- package/README.md +261 -0
- package/action.yml +185 -0
- package/dist/attribution.d.ts +22 -0
- package/dist/attribution.d.ts.map +1 -0
- package/dist/attribution.js +57 -0
- package/dist/attribution.js.map +1 -0
- package/dist/cli.d.ts +21 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +242 -0
- package/dist/cli.js.map +1 -0
- package/dist/client/index.d.ts +9 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +26 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/runner-client.d.ts +41 -0
- package/dist/client/runner-client.d.ts.map +1 -0
- package/dist/client/runner-client.js +98 -0
- package/dist/client/runner-client.js.map +1 -0
- package/dist/core/capture.d.ts +50 -0
- package/dist/core/capture.d.ts.map +1 -0
- package/dist/core/capture.js +129 -0
- package/dist/core/capture.js.map +1 -0
- package/dist/core/poster.d.ts +45 -0
- package/dist/core/poster.d.ts.map +1 -0
- package/dist/core/poster.js +132 -0
- package/dist/core/poster.js.map +1 -0
- package/dist/core/stores.d.ts +35 -0
- package/dist/core/stores.d.ts.map +1 -0
- package/dist/core/stores.js +32 -0
- package/dist/core/stores.js.map +1 -0
- package/dist/core/types.d.ts +138 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/types.js +13 -0
- package/dist/core/types.js.map +1 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +48 -0
- package/dist/index.js.map +1 -0
- package/dist/platform.d.ts +6 -0
- package/dist/platform.d.ts.map +1 -0
- package/dist/platform.js +3 -0
- package/dist/platform.js.map +1 -0
- package/dist/protocol.d.ts +84 -0
- package/dist/protocol.d.ts.map +1 -0
- package/dist/protocol.js +24 -0
- package/dist/protocol.js.map +1 -0
- package/dist/providers/kernel.d.ts +53 -0
- package/dist/providers/kernel.d.ts.map +1 -0
- package/dist/providers/kernel.js +82 -0
- package/dist/providers/kernel.js.map +1 -0
- package/dist/providers/playwright.d.ts +88 -0
- package/dist/providers/playwright.d.ts.map +1 -0
- package/dist/providers/playwright.js +114 -0
- package/dist/providers/playwright.js.map +1 -0
- package/dist/providers/steel.d.ts +48 -0
- package/dist/providers/steel.d.ts.map +1 -0
- package/dist/providers/steel.js +79 -0
- package/dist/providers/steel.js.map +1 -0
- package/dist/service/config.d.ts +33 -0
- package/dist/service/config.d.ts.map +1 -0
- package/dist/service/config.js +59 -0
- package/dist/service/config.js.map +1 -0
- package/dist/service/index.d.ts +30 -0
- package/dist/service/index.d.ts.map +1 -0
- package/dist/service/index.js +53 -0
- package/dist/service/index.js.map +1 -0
- package/dist/service/live-proxy.d.ts +27 -0
- package/dist/service/live-proxy.d.ts.map +1 -0
- package/dist/service/live-proxy.js +146 -0
- package/dist/service/live-proxy.js.map +1 -0
- package/dist/service/runner.d.ts +35 -0
- package/dist/service/runner.d.ts.map +1 -0
- package/dist/service/runner.js +139 -0
- package/dist/service/runner.js.map +1 -0
- package/dist/service/serialized-provider.d.ts +20 -0
- package/dist/service/serialized-provider.d.ts.map +1 -0
- package/dist/service/serialized-provider.js +68 -0
- package/dist/service/serialized-provider.js.map +1 -0
- package/dist/service/server.d.ts +17 -0
- package/dist/service/server.d.ts.map +1 -0
- package/dist/service/server.js +159 -0
- package/dist/service/server.js.map +1 -0
- package/docs/AGENTS.md +46 -0
- package/docs/ARCHITECTURE.md +73 -0
- package/docs/DEPLOY.md +61 -0
- package/docs/GITHUB_ACTION.md +92 -0
- package/examples/demo-strategy/index.js +53 -0
- package/examples/demo-strategy/session.json +5 -0
- package/package.json +96 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AgentPoster: orchestrates one agentic publish or session probe.
|
|
3
|
+
*
|
|
4
|
+
* load session -> acquire browser (local or remote) -> verify auth ->
|
|
5
|
+
* post via the platform's web strategy -> persist refreshed session state.
|
|
6
|
+
*
|
|
7
|
+
* Platform- and infrastructure-agnostic: add a platform by registering a
|
|
8
|
+
* WebPostStrategy; move to a different browser sandbox by passing a
|
|
9
|
+
* different SessionProvider.
|
|
10
|
+
*/
|
|
11
|
+
import type { PlatformId } from '../platform';
|
|
12
|
+
import type { AgentPostContent, AgentPostResult, SessionProvider, SessionStore, WebPostStrategy } from './types';
|
|
13
|
+
export type AgentProbeResult = {
|
|
14
|
+
authenticated: boolean;
|
|
15
|
+
error?: string;
|
|
16
|
+
};
|
|
17
|
+
/** Small random pause so unattended posts do not fire at machine cadence. */
|
|
18
|
+
export declare function humanPacingDelay(minMs?: number, maxMs?: number, random?: () => number): Promise<void>;
|
|
19
|
+
export declare class AgentPoster {
|
|
20
|
+
private provider;
|
|
21
|
+
private store;
|
|
22
|
+
private opts;
|
|
23
|
+
private strategies;
|
|
24
|
+
constructor(provider: SessionProvider, store: SessionStore, opts?: {
|
|
25
|
+
pacing?: boolean;
|
|
26
|
+
});
|
|
27
|
+
register(strategy: WebPostStrategy): this;
|
|
28
|
+
supports(platform: PlatformId): boolean;
|
|
29
|
+
strategyFor(platform: PlatformId): WebPostStrategy | undefined;
|
|
30
|
+
/** Cheap authentication probe; refreshes rotated cookies when healthy. */
|
|
31
|
+
probe(input: {
|
|
32
|
+
workspaceId: string;
|
|
33
|
+
accountId: string;
|
|
34
|
+
platform: PlatformId;
|
|
35
|
+
}): Promise<AgentProbeResult>;
|
|
36
|
+
post(input: {
|
|
37
|
+
workspaceId: string;
|
|
38
|
+
accountId: string;
|
|
39
|
+
platform: PlatformId;
|
|
40
|
+
content: AgentPostContent;
|
|
41
|
+
accountHandle?: string;
|
|
42
|
+
}): Promise<AgentPostResult>;
|
|
43
|
+
private persistRefreshed;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=poster.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"poster.d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AAgB,CAAC;QAC1B,aAAa,CAAC,EAAE,MAAM,CAAC;KACxB,GAAG,OAAO,CAAC,eAAe,CAAC,CAwD3B;YAEa,gBAAgB;CAY/B"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* AgentPoster: orchestrates one agentic publish or session probe.
|
|
4
|
+
*
|
|
5
|
+
* load session -> acquire browser (local or remote) -> verify auth ->
|
|
6
|
+
* post via the platform's web strategy -> persist refreshed session state.
|
|
7
|
+
*
|
|
8
|
+
* Platform- and infrastructure-agnostic: add a platform by registering a
|
|
9
|
+
* WebPostStrategy; move to a different browser sandbox by passing a
|
|
10
|
+
* different SessionProvider.
|
|
11
|
+
*/
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.AgentPoster = void 0;
|
|
14
|
+
exports.humanPacingDelay = humanPacingDelay;
|
|
15
|
+
/** Small random pause so unattended posts do not fire at machine cadence. */
|
|
16
|
+
async function humanPacingDelay(minMs = 1500, maxMs = 6000, random = Math.random) {
|
|
17
|
+
const ms = Math.floor(minMs + random() * (maxMs - minMs));
|
|
18
|
+
await new Promise((r) => setTimeout(r, ms));
|
|
19
|
+
}
|
|
20
|
+
class AgentPoster {
|
|
21
|
+
provider;
|
|
22
|
+
store;
|
|
23
|
+
opts;
|
|
24
|
+
strategies = new Map();
|
|
25
|
+
constructor(provider, store, opts = {}) {
|
|
26
|
+
this.provider = provider;
|
|
27
|
+
this.store = store;
|
|
28
|
+
this.opts = opts;
|
|
29
|
+
}
|
|
30
|
+
register(strategy) {
|
|
31
|
+
this.strategies.set(strategy.platform, strategy);
|
|
32
|
+
return this;
|
|
33
|
+
}
|
|
34
|
+
supports(platform) {
|
|
35
|
+
return this.strategies.has(platform);
|
|
36
|
+
}
|
|
37
|
+
strategyFor(platform) {
|
|
38
|
+
return this.strategies.get(platform);
|
|
39
|
+
}
|
|
40
|
+
/** Cheap authentication probe; refreshes rotated cookies when healthy. */
|
|
41
|
+
async probe(input) {
|
|
42
|
+
const strategy = this.strategies.get(input.platform);
|
|
43
|
+
if (!strategy) {
|
|
44
|
+
return {
|
|
45
|
+
authenticated: false,
|
|
46
|
+
error: `No agentic strategy registered for ${input.platform}`,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
const key = { workspaceId: input.workspaceId, accountId: input.accountId };
|
|
50
|
+
const state = await this.store.load(key);
|
|
51
|
+
if (!state) {
|
|
52
|
+
return { authenticated: false, error: 'No agent session captured' };
|
|
53
|
+
}
|
|
54
|
+
const handle = await this.provider.acquire({
|
|
55
|
+
platform: input.platform,
|
|
56
|
+
state,
|
|
57
|
+
});
|
|
58
|
+
try {
|
|
59
|
+
const authenticated = await strategy.isAuthenticated(handle.context);
|
|
60
|
+
if (authenticated) {
|
|
61
|
+
await this.persistRefreshed(key, state, await handle.exportState());
|
|
62
|
+
}
|
|
63
|
+
return { authenticated };
|
|
64
|
+
}
|
|
65
|
+
finally {
|
|
66
|
+
await handle.dispose();
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
async post(input) {
|
|
70
|
+
const strategy = this.strategies.get(input.platform);
|
|
71
|
+
if (!strategy) {
|
|
72
|
+
return {
|
|
73
|
+
ok: false,
|
|
74
|
+
failureStage: 'precheck',
|
|
75
|
+
error: `No agentic strategy registered for ${input.platform}`,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
const invalid = strategy.validate(input.content);
|
|
79
|
+
if (invalid) {
|
|
80
|
+
return { ok: false, failureStage: 'precheck', error: invalid };
|
|
81
|
+
}
|
|
82
|
+
const key = { workspaceId: input.workspaceId, accountId: input.accountId };
|
|
83
|
+
const state = await this.store.load(key);
|
|
84
|
+
if (!state) {
|
|
85
|
+
return {
|
|
86
|
+
ok: false,
|
|
87
|
+
needsReauth: true,
|
|
88
|
+
failureStage: 'auth',
|
|
89
|
+
error: 'No agent session captured — link the account session first',
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
const handle = await this.provider.acquire({
|
|
93
|
+
platform: input.platform,
|
|
94
|
+
state,
|
|
95
|
+
});
|
|
96
|
+
try {
|
|
97
|
+
if (!(await strategy.isAuthenticated(handle.context))) {
|
|
98
|
+
return {
|
|
99
|
+
ok: false,
|
|
100
|
+
needsReauth: true,
|
|
101
|
+
failureStage: 'auth',
|
|
102
|
+
error: 'Session expired — re-link the account session',
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
if (this.opts.pacing !== false) {
|
|
106
|
+
await humanPacingDelay();
|
|
107
|
+
}
|
|
108
|
+
const result = await strategy.post(handle.context, input.content, {
|
|
109
|
+
accountHandle: input.accountHandle,
|
|
110
|
+
});
|
|
111
|
+
// Persist rotated cookies so long-lived sessions keep working. Also
|
|
112
|
+
// done for uncertain results: the session itself is still valid.
|
|
113
|
+
if (result.ok || result.uncertain) {
|
|
114
|
+
await this.persistRefreshed(key, state, await handle.exportState());
|
|
115
|
+
}
|
|
116
|
+
return result;
|
|
117
|
+
}
|
|
118
|
+
finally {
|
|
119
|
+
await handle.dispose();
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
async persistRefreshed(key, previous, storageState) {
|
|
123
|
+
const refreshed = {
|
|
124
|
+
...previous,
|
|
125
|
+
storageState,
|
|
126
|
+
capturedAt: new Date().toISOString(),
|
|
127
|
+
};
|
|
128
|
+
await this.store.save(key, refreshed).catch(() => undefined);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
exports.AgentPoster = AgentPoster;
|
|
132
|
+
//# sourceMappingURL=poster.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"poster.js","sourceRoot":"","sources":["../../src/core/poster.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;;AAiBH,6EAA6E;AACtE,KAAK,2BACV,KAAK,GAAG,IAAI,EACZ,KAAK,GAAG,IAAI,EACZ,MAAM,GAAiB,IAAI,CAAC,MAAM;IAElC,MAAM,EAAE,GAAG,I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AAM,CAAC,OAAO,EAAE,CAAC;QACzB,CAAC;IACH,CAAC;IAEO,KAAK,CAAC,gBAAgB,CAC5B,GAA+C,EAC/C,QAA2B,EAC3B,YAA+C;QAE/C,MAAM,SAAS,GAAsB;YACnC,GAAG,QAAQ;YACX,YAAY;YACZ,UAAU,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;SACrC,CAAC;QACF,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;IAC/D,CAAC;CACF"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session stores with no external dependencies. The runner service uses
|
|
3
|
+
* `InMemorySessionStore` per request: the orchestrator hands it the decrypted
|
|
4
|
+
* state, the poster reads/writes it, and the refreshed state is returned to
|
|
5
|
+
* the orchestrator, which re-encrypts and persists it (the orchestrator's
|
|
6
|
+
* store stays the source of truth).
|
|
7
|
+
*/
|
|
8
|
+
import type { AgentSessionState, SessionStore } from './types';
|
|
9
|
+
export declare class InMemorySessionStore implements SessionStore {
|
|
10
|
+
private map;
|
|
11
|
+
static keyOf(key: {
|
|
12
|
+
workspaceId: string;
|
|
13
|
+
accountId: string;
|
|
14
|
+
}): string;
|
|
15
|
+
constructor(seed?: Array<[
|
|
16
|
+
{
|
|
17
|
+
workspaceId: string;
|
|
18
|
+
accountId: string;
|
|
19
|
+
},
|
|
20
|
+
AgentSessionState
|
|
21
|
+
]>);
|
|
22
|
+
load(key: {
|
|
23
|
+
workspaceId: string;
|
|
24
|
+
accountId: string;
|
|
25
|
+
}): Promise<AgentSessionState | null>;
|
|
26
|
+
save(key: {
|
|
27
|
+
workspaceId: string;
|
|
28
|
+
accountId: string;
|
|
29
|
+
}, state: AgentSessionState): Promise<void>;
|
|
30
|
+
peek(key: {
|
|
31
|
+
workspaceId: string;
|
|
32
|
+
accountId: string;
|
|
33
|
+
}): AgentSessionState | null;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=stores.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stores.d.ts","sourceRoot":"","sources":["../../src/core/stores.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE/D,qBAAa,oBAAqB,YAAW,YAAY;IACvD,OAAO,CAAC,GAAG,CAAwC;IAEnD,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,GAAG,MAAM,CAEpE;IAED,YACE,IAAI,CAAC,EAAE,KAAK,CACV;QAAC;YAAE,WAAW,EAAE,MAAM,CAAC;YAAC,SAAS,EAAE,MAAM,CAAA;SAAE;QAAE,iBAAiB;KAAC,CAChE,EAKF;IAEK,IAAI,CAAC,GAAG,EAAE;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,qCAEzD;IAEK,IAAI,CACR,GAAG,EAAE;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,EAC/C,KAAK,EAAE,iBAAiB,iBAGzB;IAED,IAAI,CAAC,GAAG,EAAE;QACR,WAAW,EAAE,MAAM,CAAC;QACpB,SAAS,EAAE,MAAM,CAAC;KACnB,GAAG,iBAAiB,GAAG,IAAI,CAE3B;CACF"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Session stores with no external dependencies. The runner service uses
|
|
4
|
+
* `InMemorySessionStore` per request: the orchestrator hands it the decrypted
|
|
5
|
+
* state, the poster reads/writes it, and the refreshed state is returned to
|
|
6
|
+
* the orchestrator, which re-encrypts and persists it (the orchestrator's
|
|
7
|
+
* store stays the source of truth).
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.InMemorySessionStore = void 0;
|
|
11
|
+
class InMemorySessionStore {
|
|
12
|
+
map = new Map();
|
|
13
|
+
static keyOf(key) {
|
|
14
|
+
return `${key.workspaceId}/${key.accountId}`;
|
|
15
|
+
}
|
|
16
|
+
constructor(seed) {
|
|
17
|
+
for (const [key, state] of seed ?? []) {
|
|
18
|
+
this.map.set(InMemorySessionStore.keyOf(key), state);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
async load(key) {
|
|
22
|
+
return this.map.get(InMemorySessionStore.keyOf(key)) ?? null;
|
|
23
|
+
}
|
|
24
|
+
async save(key, state) {
|
|
25
|
+
this.map.set(InMemorySessionStore.keyOf(key), state);
|
|
26
|
+
}
|
|
27
|
+
peek(key) {
|
|
28
|
+
return this.map.get(InMemorySessionStore.keyOf(key)) ?? null;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.InMemorySessionStore = InMemorySessionStore;
|
|
32
|
+
//# sourceMappingURL=stores.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stores.js","sourceRoot":"","sources":["../../src/core/stores.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAIH;IACU,GAAG,GAAG,IAAI,GAAG,EAA6B,CAAC;IAEnD,MAAM,CAAC,KAAK,CAAC,GAA+C;QAC1D,OAAO,GAAG,GAAG,CAAC,WAAW,IAAI,GAAG,CAAC,SAAS,EAAE,CAAC;IAC/C,CAAC;IAED,YACE,IAEC;QAED,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,IAAI,IAAI,EAAE,EAAE,CAAC;YACtC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,oBAAoB,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC,CAAC;QACvD,CAAC;IACH,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,GAA+C;QACxD,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,oBAAoB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,IAAI,CAAC;IAC/D,CAAC;IAED,KAAK,CAAC,IAAI,CACR,GAA+C,EAC/C,KAAwB;QAExB,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,oBAAoB,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC,CAAC;IACvD,CAAC;IAED,IAAI,CAAC,GAGJ;QACC,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,oBAAoB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,IAAI,CAAC;IAC/D,CAAC;CACF"}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session-based agentic posting: core contracts.
|
|
3
|
+
*
|
|
4
|
+
* Instead of username/password automation, an *agent session* reuses a real
|
|
5
|
+
* authenticated browser session (cookies + storage) that the user granted to
|
|
6
|
+
* your application. Sessions are provider-agnostic: they can live in a local
|
|
7
|
+
* browser (dev / self-hosted runner), or in a remote browser reachable over
|
|
8
|
+
* CDP (self-hosted Steel, Kernel, Browserbase) so the user's machine never
|
|
9
|
+
* needs to be online at publish time.
|
|
10
|
+
*/
|
|
11
|
+
import type { BrowserContext } from 'playwright-core';
|
|
12
|
+
import type { PlatformId } from '../platform';
|
|
13
|
+
/** Playwright `storageState`-compatible payload (cookies + origins). */
|
|
14
|
+
export type StorageState = {
|
|
15
|
+
cookies: Array<{
|
|
16
|
+
name: string;
|
|
17
|
+
value: string;
|
|
18
|
+
domain: string;
|
|
19
|
+
path: string;
|
|
20
|
+
expires: number;
|
|
21
|
+
httpOnly: boolean;
|
|
22
|
+
secure: boolean;
|
|
23
|
+
sameSite: 'Strict' | 'Lax' | 'None';
|
|
24
|
+
}>;
|
|
25
|
+
origins: Array<{
|
|
26
|
+
origin: string;
|
|
27
|
+
localStorage: Array<{
|
|
28
|
+
name: string;
|
|
29
|
+
value: string;
|
|
30
|
+
}>;
|
|
31
|
+
}>;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Serialized browser session state for one user + platform. The source of
|
|
35
|
+
* truth is the embedding application's encrypted store (treat it with
|
|
36
|
+
* password-equivalent sensitivity and never expose it to end-user clients).
|
|
37
|
+
* Remote browser profiles are only a warm cache.
|
|
38
|
+
*/
|
|
39
|
+
export type AgentSessionState = {
|
|
40
|
+
platform: PlatformId;
|
|
41
|
+
storageState: StorageState;
|
|
42
|
+
/** UA the session was captured with; reusing it reduces re-auth. */
|
|
43
|
+
userAgent?: string;
|
|
44
|
+
capturedAt: string;
|
|
45
|
+
expiresHint?: string;
|
|
46
|
+
/** Provider-side warm profile id (e.g. Steel profileId), if any. */
|
|
47
|
+
providerProfileId?: string;
|
|
48
|
+
};
|
|
49
|
+
/** A live browser context bound to a session, plus lifecycle hooks. */
|
|
50
|
+
export type AgentSessionHandle = {
|
|
51
|
+
context: BrowserContext;
|
|
52
|
+
/** Provider-specific session id (e.g. cloud session id) for debugging. */
|
|
53
|
+
providerSessionId?: string;
|
|
54
|
+
/** Human-viewable live view (capture flows); undefined for headless jobs. */
|
|
55
|
+
liveViewUrl?: string;
|
|
56
|
+
/** Export the (possibly refreshed) session state before release. */
|
|
57
|
+
exportState(): Promise<StorageState>;
|
|
58
|
+
/** Release the context/browser; must be called in a finally block. */
|
|
59
|
+
dispose(): Promise<void>;
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Turns stored session state into a live browser context. Implementations:
|
|
63
|
+
* - LocalBrowserSessionProvider: local Playwright Chromium (runner, dev)
|
|
64
|
+
* - CdpSessionProvider: any remote browser exposing a CDP websocket
|
|
65
|
+
* - SteelSessionProvider: self-hosted Steel (CDP + live view for capture)
|
|
66
|
+
*/
|
|
67
|
+
export interface SessionProvider {
|
|
68
|
+
readonly id: string;
|
|
69
|
+
acquire(input: {
|
|
70
|
+
platform: PlatformId;
|
|
71
|
+
state?: AgentSessionState;
|
|
72
|
+
/** Request a live view (interactive capture). Not all providers can. */
|
|
73
|
+
interactive?: boolean;
|
|
74
|
+
}): Promise<AgentSessionHandle>;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Persistence for session state. Production implementations should encrypt
|
|
78
|
+
* at rest (e.g. AES-256-GCM); tests and the runner use an in-memory store.
|
|
79
|
+
*/
|
|
80
|
+
export interface SessionStore {
|
|
81
|
+
load(key: {
|
|
82
|
+
workspaceId: string;
|
|
83
|
+
accountId: string;
|
|
84
|
+
}): Promise<AgentSessionState | null>;
|
|
85
|
+
save(key: {
|
|
86
|
+
workspaceId: string;
|
|
87
|
+
accountId: string;
|
|
88
|
+
}, state: AgentSessionState): Promise<void>;
|
|
89
|
+
}
|
|
90
|
+
/** Content handed to a platform strategy. */
|
|
91
|
+
export type AgentPostContent = {
|
|
92
|
+
text: string;
|
|
93
|
+
mediaUrls?: string[];
|
|
94
|
+
link?: string;
|
|
95
|
+
};
|
|
96
|
+
export type AgentPostFailureStage = 'precheck' | 'auth' | 'compose' | 'media' | 'submit' | 'verify';
|
|
97
|
+
/** How a successful post was confirmed. */
|
|
98
|
+
export type AgentPostVerification = 'toast' | 'timeline';
|
|
99
|
+
/** Result of an agentic post attempt. */
|
|
100
|
+
export type AgentPostResult = {
|
|
101
|
+
ok: boolean;
|
|
102
|
+
platformPostId?: string;
|
|
103
|
+
platformPostUrl?: string;
|
|
104
|
+
verification?: AgentPostVerification;
|
|
105
|
+
/** Session became invalid (logged out) — user must re-link. */
|
|
106
|
+
needsReauth?: boolean;
|
|
107
|
+
/**
|
|
108
|
+
* The submit action ran but the outcome could not be verified. Callers
|
|
109
|
+
* MUST NOT retry or fall back to another delivery path, or the user may
|
|
110
|
+
* end up with a duplicate post. Surface for manual review instead.
|
|
111
|
+
*/
|
|
112
|
+
uncertain?: boolean;
|
|
113
|
+
failureStage?: AgentPostFailureStage;
|
|
114
|
+
error?: string;
|
|
115
|
+
/** PNG screenshot captured at the failure point (never sent to clients). */
|
|
116
|
+
screenshotBase64?: string;
|
|
117
|
+
};
|
|
118
|
+
/**
|
|
119
|
+
* Platform posting strategy driving the real web UI through a Page.
|
|
120
|
+
* One implementation per platform keeps selectors/quirks isolated.
|
|
121
|
+
*/
|
|
122
|
+
export interface WebPostStrategy {
|
|
123
|
+
readonly platform: PlatformId;
|
|
124
|
+
/** Sign-in page to open for interactive capture. */
|
|
125
|
+
readonly loginUrl: string;
|
|
126
|
+
/** Quick probe: is this context still authenticated? */
|
|
127
|
+
isAuthenticated(context: BrowserContext): Promise<boolean>;
|
|
128
|
+
/**
|
|
129
|
+
* Validate content before any browser work (length limits, media count).
|
|
130
|
+
* Returns an error string when the content can never be posted as-is.
|
|
131
|
+
*/
|
|
132
|
+
validate(content: AgentPostContent): string | null;
|
|
133
|
+
post(context: BrowserContext, content: AgentPostContent, opts?: {
|
|
134
|
+
/** Account handle (without @) used for timeline verification. */
|
|
135
|
+
accountHandle?: string;
|
|
136
|
+
}): Promise<AgentPostResult>;
|
|
137
|
+
}
|
|
138
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,wEAAwE;AACxE,MAAM,MAAM,YAAY,GAAG;IACzB,OAAO,EAAE,KAAK,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;QACf,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,QAAQ,EAAE,OAAO,CAAC;QAClB,MAAM,EAAE,OAAO,CAAC;QAChB,QAAQ,EAAE,QAAQ,GAAG,KAAK,G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,OAAO,CAAC,CAAC;IAC3D;;;OAGG;IACH,QAAQ,CAAC,OAAO,EAAE,gBAAgB,GAAG,MAAM,GAAG,IAAI,CAAC;IACnD,IAAI,CACF,OAAO,EAAE,cAAc,EACvB,OAAO,EAAE,gBAAgB,EACzB,IAAI,CAAC,EAAE;QACL,iEAAiE;QACjE,aAAa,CAAC,EAAE,MAAM,CAAC;KACxB,GACA,OAAO,CAAC,eAAe,CAAC,CAAC;CAC7B"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Session-based agentic posting: core contracts.
|
|
4
|
+
*
|
|
5
|
+
* Instead of username/password automation, an *agent session* reuses a real
|
|
6
|
+
* authenticated browser session (cookies + storage) that the user granted to
|
|
7
|
+
* your application. Sessions are provider-agnostic: they can live in a local
|
|
8
|
+
* browser (dev / self-hosted runner), or in a remote browser reachable over
|
|
9
|
+
* CDP (self-hosted Steel, Kernel, Browserbase) so the user's machine never
|
|
10
|
+
* needs to be online at publish time.
|
|
11
|
+
*/
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* agent-browser-runtime — stateful, secure browser-session execution for
|
|
3
|
+
* agents: session contracts, orchestration (post / probe / capture),
|
|
4
|
+
* pluggable browser providers (local Chromium, any CDP endpoint, Steel,
|
|
5
|
+
* Kernel), and an HTTP runner service with a Playwright-free client.
|
|
6
|
+
*
|
|
7
|
+
* Platform behaviour is supplied by the embedding app as `WebPostStrategy`
|
|
8
|
+
* implementations; this package never hard-codes a platform.
|
|
9
|
+
*/
|
|
10
|
+
export { AgentRunnerClient, type AgentRunnerClientOptions, AgentRunnerError, } from './client/runner-client';
|
|
11
|
+
export { SessionCaptureManager } from './core/capture';
|
|
12
|
+
export { AgentPoster, humanPacingDelay } from './core/poster';
|
|
13
|
+
export { InMemorySessionStore } from './core/stores';
|
|
14
|
+
export * from './core/types';
|
|
15
|
+
export type { PlatformId } from './platform';
|
|
16
|
+
export * from './protocol';
|
|
17
|
+
export { type KernelProviderOptions, KernelSessionProvider, } from './providers/kernel';
|
|
18
|
+
export { attachOverCdp, buildHandle, CdpSessionProvider, LocalBrowserSessionProvider, } from './providers/playwright';
|
|
19
|
+
export { type SteelProviderOptions, SteelSessionProvider, } from './providers/steel';
|
|
20
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EACL,iBAAiB,EACjB,KAAK,wBAAwB,EAC7B,gBAAgB,GACjB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAC9D,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACrD,cAAc,cAAc,CAAC;AAC7B,YAAY,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,cAAc,YAAY,CAAC;AAC3B,OAAO,EACL,KAAK,qBAAqB,EAC1B,qBAAqB,GACtB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,aAAa,EACb,WAAW,EACX,kBAAkB,EAClB,2BAA2B,GAC5B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,KAAK,oBAAoB,EACzB,oBAAoB,GACrB,MAAM,mBAAmB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* agent-browser-runtime — stateful, secure browser-session execution for
|
|
4
|
+
* agents: session contracts, orchestration (post / probe / capture),
|
|
5
|
+
* pluggable browser providers (local Chromium, any CDP endpoint, Steel,
|
|
6
|
+
* Kernel), and an HTTP runner service with a Playwright-free client.
|
|
7
|
+
*
|
|
8
|
+
* Platform behaviour is supplied by the embedding app as `WebPostStrategy`
|
|
9
|
+
* implementations; this package never hard-codes a platform.
|
|
10
|
+
*/
|
|
11
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
12
|
+
if (k2 === undefined) k2 = k;
|
|
13
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
14
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
15
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
16
|
+
}
|
|
17
|
+
Object.defineProperty(o, k2, desc);
|
|
18
|
+
}) : (function(o, m, k, k2) {
|
|
19
|
+
if (k2 === undefined) k2 = k;
|
|
20
|
+
o[k2] = m[k];
|
|
21
|
+
}));
|
|
22
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
23
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.SteelSessionProvider = exports.LocalBrowserSessionProvider = exports.CdpSessionProvider = exports.buildHandle = exports.attachOverCdp = exports.KernelSessionProvider = exports.InMemorySessionStore = exports.humanPacingDelay = exports.AgentPoster = exports.SessionCaptureManager = exports.AgentRunnerError = exports.AgentRunnerClient = void 0;
|
|
27
|
+
var runner_client_1 = require("./client/runner-client");
|
|
28
|
+
Object.defineProperty(exports, "AgentRunnerClient", { enumerable: true, get: function () { return runner_client_1.AgentRunnerClient; } });
|
|
29
|
+
Object.defineProperty(exports, "AgentRunnerError", { enumerable: true, get: function () { return runner_client_1.AgentRunnerError; } });
|
|
30
|
+
var capture_1 = require("./core/capture");
|
|
31
|
+
Object.defineProperty(exports, "SessionCaptureManager", { enumerable: true, get: function () { return capture_1.SessionCaptureManager; } });
|
|
32
|
+
var poster_1 = require("./core/poster");
|
|
33
|
+
Object.defineProperty(exports, "AgentPoster", { enumerable: true, get: function () { return poster_1.AgentPoster; } });
|
|
34
|
+
Object.defineProperty(exports, "humanPacingDelay", { enumerable: true, get: function () { return poster_1.humanPacingDelay; } });
|
|
35
|
+
var stores_1 = require("./core/stores");
|
|
36
|
+
Object.defineProperty(exports, "InMemorySessionStore", { enumerable: true, get: function () { return stores_1.InMemorySessionStore; } });
|
|
37
|
+
__exportStar(require("./core/types"), exports);
|
|
38
|
+
__exportStar(require("./protocol"), exports);
|
|
39
|
+
var kernel_1 = require("./providers/kernel");
|
|
40
|
+
Object.defineProperty(exports, "KernelSessionProvider", { enumerable: true, get: function () { return kernel_1.KernelSessionProvider; } });
|
|
41
|
+
var playwright_1 = require("./providers/playwright");
|
|
42
|
+
Object.defineProperty(exports, "attachOverCdp", { enumerable: true, get: function () { return playwright_1.attachOverCdp; } });
|
|
43
|
+
Object.defineProperty(exports, "buildHandle", { enumerable: true, get: function () { return playwright_1.buildHandle; } });
|
|
44
|
+
Object.defineProperty(exports, "CdpSessionProvider", { enumerable: true, get: function () { return playwright_1.CdpSessionProvider; } });
|
|
45
|
+
Object.defineProperty(exports, "LocalBrowserSessionProvider", { enumerable: true, get: function () { return playwright_1.LocalBrowserSessionProvider; } });
|
|
46
|
+
var steel_1 = require("./providers/steel");
|
|
47
|
+
Object.defineProperty(exports, "SteelSessionProvider", { enumerable: true, get: function () { return steel_1.SteelSessionProvider; } });
|
|
48
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;;;;;;;;;;;;;;;AAEH,wDAIgC;AAH9B,kHAAA,iBAAiB,OAAA;AAEjB,iHAAA,gBAAgB,OAAA;AAElB,0CAAuD;AAA9C,gHAAA,qBAAqB,OAAA;AAC9B,wCAA8D;AAArD,qGAAA,WAAW,OAAA;AAAE,0GAAA,gBAAgB,OAAA;AACtC,wCAAqD;AAA5C,8GAAA,oBAAoB,OAAA;AAC7B,+CAA6B;AAE7B,6CAA2B;AAC3B,6CAG4B;AAD1B,+GAAA,qBAAqB,OAAA;AAEvB,qDAKgC;AAJ9B,2GAAA,aAAa,OAAA;AACb,yGAAA,WAAW,OAAA;AACX,gHAAA,kBAAkB,OAAA;AAClB,yHAAA,2BAA2B,OAAA;AAE7B,2CAG2B;AADzB,6GAAA,oBAAoB,OAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../src/platform.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC"}
|
package/dist/platform.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"platform.js","sourceRoot":"","sources":["../src/platform.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wire protocol between an orchestrator (serverless function, queue worker,
|
|
3
|
+
* cron job) and the agent runner service. Pure types — safe to import from
|
|
4
|
+
* code that must not pull in Playwright.
|
|
5
|
+
*
|
|
6
|
+
* The orchestrator owns session persistence: every request carries the
|
|
7
|
+
* decrypted session state and every response may carry a refreshed one,
|
|
8
|
+
* which the orchestrator re-encrypts into its own store. The runner keeps
|
|
9
|
+
* nothing between requests except in-flight interactive captures.
|
|
10
|
+
*/
|
|
11
|
+
import type { AgentPostContent, AgentPostFailureStage, AgentPostVerification, AgentSessionState } from './core/types';
|
|
12
|
+
import type { PlatformId } from './platform';
|
|
13
|
+
export declare const RUNNER_ROUTES: {
|
|
14
|
+
readonly health: '/healthz';
|
|
15
|
+
readonly post: '/v1/post';
|
|
16
|
+
readonly probe: '/v1/probe';
|
|
17
|
+
readonly captureStart: '/v1/capture/start';
|
|
18
|
+
readonly captureFinish: '/v1/capture/finish';
|
|
19
|
+
readonly captureCancel: '/v1/capture/cancel';
|
|
20
|
+
/** `${live}/{captureId}/...` proxies the provider live view. */
|
|
21
|
+
readonly live: '/live';
|
|
22
|
+
};
|
|
23
|
+
export type RunnerPostRequest = {
|
|
24
|
+
/** Idempotency / trace id, e.g. `${workspaceId}/${postId}#${targetIndex}`. */
|
|
25
|
+
jobId: string;
|
|
26
|
+
workspaceId: string;
|
|
27
|
+
accountId: string;
|
|
28
|
+
platform: PlatformId;
|
|
29
|
+
accountHandle?: string;
|
|
30
|
+
content: AgentPostContent;
|
|
31
|
+
session: AgentSessionState;
|
|
32
|
+
};
|
|
33
|
+
export type RunnerPostResponse = {
|
|
34
|
+
ok: boolean;
|
|
35
|
+
platformPostId?: string;
|
|
36
|
+
platformPostUrl?: string;
|
|
37
|
+
verification?: AgentPostVerification;
|
|
38
|
+
needsReauth?: boolean;
|
|
39
|
+
uncertain?: boolean;
|
|
40
|
+
failureStage?: AgentPostFailureStage;
|
|
41
|
+
error?: string;
|
|
42
|
+
screenshotBase64?: string;
|
|
43
|
+
refreshedSession?: AgentSessionState;
|
|
44
|
+
runner?: {
|
|
45
|
+
provider: string;
|
|
46
|
+
durationMs: number;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
export type RunnerProbeRequest = {
|
|
50
|
+
workspaceId: string;
|
|
51
|
+
accountId: string;
|
|
52
|
+
platform: PlatformId;
|
|
53
|
+
session: AgentSessionState;
|
|
54
|
+
};
|
|
55
|
+
export type RunnerProbeResponse = {
|
|
56
|
+
authenticated: boolean;
|
|
57
|
+
error?: string;
|
|
58
|
+
refreshedSession?: AgentSessionState;
|
|
59
|
+
};
|
|
60
|
+
export type RunnerCaptureStartRequest = {
|
|
61
|
+
platform: PlatformId;
|
|
62
|
+
userAgent?: string;
|
|
63
|
+
};
|
|
64
|
+
export type RunnerCaptureStartResponse = {
|
|
65
|
+
captureId: string;
|
|
66
|
+
/** Absolute URL the embedding app can load in an iframe. */
|
|
67
|
+
liveViewUrl: string;
|
|
68
|
+
expiresAt: string;
|
|
69
|
+
};
|
|
70
|
+
export type RunnerCaptureFinishRequest = {
|
|
71
|
+
captureId: string;
|
|
72
|
+
};
|
|
73
|
+
export type RunnerCaptureFinishResponse = {
|
|
74
|
+
ok: true;
|
|
75
|
+
state: AgentSessionState;
|
|
76
|
+
} | {
|
|
77
|
+
ok: false;
|
|
78
|
+
error: string;
|
|
79
|
+
notAuthenticated?: boolean;
|
|
80
|
+
};
|
|
81
|
+
export type RunnerErrorResponse = {
|
|
82
|
+
error: string;
|
|
83
|
+
};
|
|
84
|
+
//# sourceMappingURL=protocol.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EACV,gBAAgB,EAChB,qBAAqB,EACrB,qBAAqB,EACrB,iBAAiB,EAClB,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,eAAO,MAAM,aAAa;aACxB,MAAM,EAAE,UAAU;aAClB,IAAI,EAAE,UAAU;aAChB,KAAK,EAAE,WAAW;aAClB,YAAY,EAAE,mBAAmB;aACjC,aAAa,EAAE,oBAAoB;aACnC,aAAa,EAAE,oBAAoB;IACnC,gEAAgE;aAChE,IAAI,EAAE,OAAO;CACL,CAAC;AAEX,MAAM,MAAM,iBAAiB,GAAG;IAC9B,8EAA8E;IAC9E,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,UAAU,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,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E/D,MAAM,MAAM,2BAA2B,GACnC;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,iBAAiB,CAAA;CAAE,GACtC;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,gBAAgB,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAE7D,MAAM,MAAM,mBAAmB,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC"}
|
package/dist/protocol.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Wire protocol between an orchestrator (serverless function, queue worker,
|
|
4
|
+
* cron job) and the agent runner service. Pure types — safe to import from
|
|
5
|
+
* code that must not pull in Playwright.
|
|
6
|
+
*
|
|
7
|
+
* The orchestrator owns session persistence: every request carries the
|
|
8
|
+
* decrypted session state and every response may carry a refreshed one,
|
|
9
|
+
* which the orchestrator re-encrypts into its own store. The runner keeps
|
|
10
|
+
* nothing between requests except in-flight interactive captures.
|
|
11
|
+
*/
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.RUNNER_ROUTES = void 0;
|
|
14
|
+
exports.RUNNER_ROUTES = {
|
|
15
|
+
health: '/healthz',
|
|
16
|
+
post: '/v1/post',
|
|
17
|
+
probe: '/v1/probe',
|
|
18
|
+
captureStart: '/v1/capture/start',
|
|
19
|
+
captureFinish: '/v1/capture/finish',
|
|
20
|
+
captureCancel: '/v1/capture/cancel',
|
|
21
|
+
/** `${live}/{captureId}/...` proxies the provider live view. */
|
|
22
|
+
live: '/live',
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=protocol.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocol.js","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;AAUU,QAAA,aAAa,GAAG;IAC3B,MAAM,EAAE,UAAU;IAClB,IAAI,EAAE,UAAU;IAChB,KAAK,EAAE,WAAW;IAClB,YAAY,EAAE,mBAAmB;IACjC,aAAa,EAAE,oBAAoB;IACnC,aAAa,EAAE,oBAAoB;IACnC,gEAAgE;IAChE,IAAI,EAAE,OAAO;CACL,CAAC"}
|