@dsh-enhanced/assistant-growth-driver 0.1.34

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,53 @@
1
+ import type { GoalScope, OwnerGoalExecutionSnapshotInput } from '@dsh-enhanced/assistant-goals';
2
+ import type { CommitOwnerAnchoredWorkflowTraceServiceResult } from '@dsh-enhanced/assistant-delivery';
3
+ import type { GrowthOwnerScopeConfig } from './config.js';
4
+ /**
5
+ * A growth authority is the Host-side analogue of RepairExecutionAuthority,
6
+ * but it is NOT backed by any durable repair continuation: the driver mints it
7
+ * from the frozen configured owner scope for exactly one bounded wake. It can
8
+ * draft a pending skill candidate and nothing else.
9
+ */
10
+ export interface GrowthAuthority {
11
+ readonly id: string;
12
+ readonly scope: GoalScope;
13
+ readonly ownerRouteId: string;
14
+ readonly expiresAt: number;
15
+ assertCurrent(): void;
16
+ }
17
+ export interface OwnerRouteReceipt {
18
+ readonly receiptVersion: 2;
19
+ readonly authorityId: string;
20
+ readonly authorityHash: string;
21
+ readonly principalId: string;
22
+ readonly principalRecordId: string;
23
+ readonly principalVersion: number;
24
+ readonly workspace: string;
25
+ readonly agentPreset: string;
26
+ readonly bindingVersion: number;
27
+ readonly generation: number;
28
+ }
29
+ export interface GrowthDeliveryPort {
30
+ validateOwnerRoute(input: {
31
+ authorityId: string;
32
+ principalId: string;
33
+ workspace: string;
34
+ agentPreset: string;
35
+ }): Readonly<OwnerRouteReceipt>;
36
+ /**
37
+ * Host-only owner-anchored learning seam. The driver passes only a locator
38
+ * and the bounded-wake authority; Delivery re-fetches the verified Goals
39
+ * source and run proof itself and never accepts a caller-supplied prompt.
40
+ */
41
+ commitOwnerAnchoredWorkflowTrace(input: Readonly<{
42
+ locator: OwnerGoalExecutionSnapshotInput;
43
+ authority: GrowthAuthority;
44
+ }>): Promise<Readonly<CommitOwnerAnchoredWorkflowTraceServiceResult>>;
45
+ }
46
+ /**
47
+ * Re-anchor the configured owner scope against the live authenticated Delivery
48
+ * owner route and mint one short-lived growth authority. Never derives an
49
+ * owner from model-controlled values: the route id, principal, workspace and
50
+ * preset all come from frozen plugin configuration.
51
+ */
52
+ export declare function mintGrowthAuthority(delivery: GrowthDeliveryPort, config: GrowthOwnerScopeConfig, expiresAt: number): GrowthAuthority;
53
+ //# sourceMappingURL=deposit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deposit.d.ts","sourceRoot":"","sources":["../src/deposit.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,+BAA+B,EAAE,MAAM,+BAA+B,CAAA;AAC/F,OAAO,KAAK,EAAE,6CAA6C,EAAE,MAAM,kCAAkC,CAAA;AACrG,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAEzD;;;;;GAKG;AACH,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAA;IACzB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;IAC7B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,aAAa,IAAI,IAAI,CAAA;CACtB;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,cAAc,EAAE,CAAC,CAAA;IAC1B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAC5B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAA;IAC9B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAC5B,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAA;IAClC,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAA;IACjC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAC5B,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAA;IAC/B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;CAC5B;AAED,MAAM,WAAW,kBAAkB;IACjC,kBAAkB,CAAC,KAAK,EAAE;QACxB,WAAW,EAAE,MAAM,CAAA;QACnB,WAAW,EAAE,MAAM,CAAA;QACnB,SAAS,EAAE,MAAM,CAAA;QACjB,WAAW,EAAE,MAAM,CAAA;KACpB,GAAG,QAAQ,CAAC,iBAAiB,CAAC,CAAA;IAC/B;;;;OAIG;IACH,gCAAgC,CAAC,KAAK,EAAE,QAAQ,CAAC;QAC/C,OAAO,EAAE,+BAA+B,CAAA;QACxC,SAAS,EAAE,eAAe,CAAA;KAC3B,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,6CAA6C,CAAC,CAAC,CAAA;CACtE;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,kBAAkB,EAAE,MAAM,EAAE,sBAAsB,EAAE,SAAS,EAAE,MAAM,GAAG,eAAe,CA6CpI"}
package/lib/deposit.js ADDED
@@ -0,0 +1,55 @@
1
+ import { createHash } from 'node:crypto';
2
+ import { acceptanceDigest } from '@dsh-enhanced/task-acceptance-contract';
3
+ /**
4
+ * Re-anchor the configured owner scope against the live authenticated Delivery
5
+ * owner route and mint one short-lived growth authority. Never derives an
6
+ * owner from model-controlled values: the route id, principal, workspace and
7
+ * preset all come from frozen plugin configuration.
8
+ */
9
+ export function mintGrowthAuthority(delivery, config, expiresAt) {
10
+ const anchor = delivery.validateOwnerRoute({
11
+ authorityId: config.ownerRouteId,
12
+ principalId: config.principalId,
13
+ workspace: config.workspace,
14
+ agentPreset: config.preset,
15
+ });
16
+ if (anchor.principalId !== config.principalId || anchor.workspace !== config.workspace
17
+ || anchor.agentPreset !== config.preset || anchor.authorityId !== config.ownerRouteId) {
18
+ throw new Error('assistant-growth-driver: owner route receipt does not match the configured scope');
19
+ }
20
+ const scope = Object.freeze({
21
+ principalId: config.principalId,
22
+ principalRecordId: anchor.principalRecordId,
23
+ principalVersion: anchor.principalVersion,
24
+ workspace: config.workspace,
25
+ preset: config.preset,
26
+ });
27
+ const anchorDigest = acceptanceDigest(anchor);
28
+ const id = `growth-${createHash('sha256')
29
+ .update(acceptanceDigest({ scope, ownerRouteId: config.ownerRouteId, expiresAt, anchorDigest }))
30
+ .digest('hex')
31
+ .slice(0, 40)}`;
32
+ return Object.freeze({
33
+ id,
34
+ scope,
35
+ ownerRouteId: config.ownerRouteId,
36
+ expiresAt,
37
+ assertCurrent() {
38
+ if (!Number.isSafeInteger(expiresAt) || expiresAt <= Date.now()) {
39
+ throw new Error('assistant-growth-driver: growth authority expired');
40
+ }
41
+ // Re-read the owner route on every use: a revoked/rebound delivery route
42
+ // or a principal generation change invalidates the whole wake.
43
+ const current = delivery.validateOwnerRoute({
44
+ authorityId: config.ownerRouteId,
45
+ principalId: config.principalId,
46
+ workspace: config.workspace,
47
+ agentPreset: config.preset,
48
+ });
49
+ if (acceptanceDigest(current) !== anchorDigest) {
50
+ throw new Error('assistant-growth-driver: owner route changed during growth wake');
51
+ }
52
+ },
53
+ });
54
+ }
55
+ //# sourceMappingURL=deposit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deposit.js","sourceRoot":"","sources":["../src/deposit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAA;AAkDzE;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CAAC,QAA4B,EAAE,MAA8B,EAAE,SAAiB;IACjH,MAAM,MAAM,GAAG,QAAQ,CAAC,kBAAkB,CAAC;QACzC,WAAW,EAAE,MAAM,CAAC,YAAY;QAChC,WAAW,EAAE,MAAM,CAAC,WAAW;QAC/B,SAAS,EAAE,MAAM,CAAC,SAAS;QAC3B,WAAW,EAAE,MAAM,CAAC,MAAM;KAC3B,CAAC,CAAA;IACF,IAAI,MAAM,CAAC,WAAW,KAAK,MAAM,CAAC,WAAW,IAAI,MAAM,CAAC,SAAS,KAAK,MAAM,CAA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,SAAS;gBAC3B,WAAW,EAAE,MAAM,CAAC,MAAM;aAC3B,CAAC,CAAA;YACF,IAAI,gBAAgB,CAAC,OAAO,CAAC,KAAK,YAAY,EAAE,CAAC;gBAC/C,MAAM,IAAI,KAAK,CAAC,iEAAiE,CAAC,CAAA;YACpF,CAAC;QACH,CAAC;KACF,CAAC,CAAA;AACJ,CAAC"}
@@ -0,0 +1,63 @@
1
+ import type { Context } from '@deepseek-ai/cordis';
2
+ import { type ModelSelection } from '@deepseek-ai/dsh-agent';
3
+ import type { AssistantGoalsService } from '@dsh-enhanced/assistant-goals';
4
+ import type { AssistantSkillsService } from '@dsh-enhanced/assistant-skills';
5
+ import type { NormalizedGrowthDriverConfig } from './config.js';
6
+ import type { GrowthAuthority } from './deposit.js';
7
+ import { type GrowthSourcePlanePort } from './source-port.js';
8
+ export declare const GROWTH_PROMPT: string;
9
+ /**
10
+ * Extra prompt section mounted ONLY when the owner opted into
11
+ * pluginSourceProposals. It defines the three source tools and the hard
12
+ * boundaries around the isolated modify lane.
13
+ */
14
+ export declare const SOURCE_PROPOSALS_PROMPT: string;
15
+ export interface GrowthSourceWakeCounters {
16
+ readonly queued: number;
17
+ readonly prepared: number;
18
+ readonly rejected: number;
19
+ }
20
+ export interface GrowthAgentRunResult {
21
+ readonly model: Readonly<ModelSelection>;
22
+ readonly sessionId: string;
23
+ readonly outcome: 'succeeded' | 'cancelled' | 'failed' | 'unknown';
24
+ readonly output: string;
25
+ readonly usage: {
26
+ inputTokens: number;
27
+ outputTokens: number;
28
+ cacheReadTokens: number;
29
+ cacheWriteTokens: number;
30
+ reasoningTokens: number;
31
+ modelCalls: number;
32
+ toolCalls: number;
33
+ };
34
+ /** Zeroed unless the owner opted into pluginSourceProposals and a source port is bound. */
35
+ readonly sourceProposals: GrowthSourceWakeCounters;
36
+ }
37
+ type Goals = Pick<AssistantGoalsService, 'inspectOwnerGoals' | 'inspectOwnerVerifiedWorkflowSource'>;
38
+ type Skills = Pick<AssistantSkillsService, 'inspectOwnerActiveSkills' | 'inspectOwnerSkillCandidates' | 'stageOwnerVerifiedSuccessCandidate'>;
39
+ export interface GrowthAgentInput {
40
+ wakeId: string;
41
+ authority: GrowthAuthority;
42
+ config: NormalizedGrowthDriverConfig;
43
+ model: Readonly<ModelSelection>;
44
+ goals: Goals;
45
+ skills: Skills;
46
+ /**
47
+ * Bound ONLY when pluginSourceProposals is enabled AND a pluginControlPlane
48
+ * service is mounted. When undefined, the three source tools are not registered
49
+ * and the exact-surface contract is the frozen four-tool baseline.
50
+ */
51
+ sourcePlane?: GrowthSourcePlanePort;
52
+ signal?: AbortSignal;
53
+ /** Actual task context is data, never authority or independent success proof. */
54
+ feedback?: import('@dsh-enhanced/assistant-delivery').OwnerForegroundLearningTask;
55
+ }
56
+ /**
57
+ * Create, run to idle and dispose exactly one bounded growth agent. Never
58
+ * mounts a preset: the complete tool surface is the four growth_* realm tools,
59
+ * and any extra visible tool fails closed before the prompt is submitted.
60
+ */
61
+ export declare function runGrowthAgent(ctx: Context, input: GrowthAgentInput): Promise<GrowthAgentRunResult>;
62
+ export {};
63
+ //# sourceMappingURL=growth-agent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"growth-agent.d.ts","sourceRoot":"","sources":["../src/growth-agent.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,EAAuD,KAAK,cAAc,EAAE,MAAM,wBAAwB,CAAA;AAKjH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAA;AAE1E,OAAO,KAAK,EAAE,sBAAsB,EAAgB,MAAM,gCAAgC,CAAA;AAC1F,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAA;AAC/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AACnD,OAAO,EAEL,KAAK,qBAAqB,EAG3B,MAAM,kBAAkB,CAAA;AAmCzB,eAAO,MAAM,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