jiva-core 0.3.2 → 0.3.22

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,31 @@
1
+ name: Build and Publish to npm
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+
7
+ jobs:
8
+ build-and-publish:
9
+ runs-on: ubuntu-latest
10
+ permissions:
11
+ contents: read
12
+ steps:
13
+ - name: Checkout repository
14
+ uses: actions/checkout@v4
15
+
16
+ - name: Set up Node.js
17
+ uses: actions/setup-node@v4
18
+ with:
19
+ node-version: '20'
20
+ registry-url: 'https://registry.npmjs.org'
21
+
22
+ - name: Install dependencies
23
+ run: npm ci --ignore-scripts
24
+
25
+ - name: Build
26
+ run: npm run build
27
+
28
+ - name: Publish to npm
29
+ run: npm publish --access public
30
+ env:
31
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
package/Dockerfile CHANGED
@@ -8,8 +8,8 @@ WORKDIR /app
8
8
  COPY package*.json ./
9
9
  COPY tsconfig.json ./
10
10
 
11
- # Install dependencies (including dev dependencies for build)
12
- RUN npm ci
11
+ # Install dependencies (skip postinstall/playwright in CI environment)
12
+ RUN npm ci --ignore-scripts
13
13
 
14
14
  # Copy source code
15
15
  COPY src ./src
@@ -28,16 +28,21 @@ RUN apk add --no-cache dumb-init
28
28
  # Copy package files
29
29
  COPY package*.json ./
30
30
 
31
- # Install production dependencies only
32
- RUN npm ci --omit=dev && npm cache clean --force
31
+ # Install production dependencies only (skip postinstall/playwright)
32
+ RUN npm ci --omit=dev --ignore-scripts && npm cache clean --force
33
+
34
+ # Pre-install MCP servers globally so they don't need to be downloaded per-session
35
+ RUN npm install -g @modelcontextprotocol/server-filesystem
33
36
 
34
37
  # Copy built application from builder
35
38
  COPY --from=builder /app/dist ./dist
36
39
 
37
- # Create non-root user
38
- RUN addgroup -g 1001 -S nodejs && \
40
+ # Create workspace directory and set permissions
41
+ RUN mkdir -p /workspace && \
42
+ addgroup -g 1001 -S nodejs && \
39
43
  adduser -S nodejs -u 1001 && \
40
- chown -R nodejs:nodejs /app
44
+ chown -R nodejs:nodejs /app && \
45
+ chown nodejs:nodejs /workspace
41
46
 
42
47
  USER nodejs
43
48
 
package/cloud-run.yaml CHANGED
@@ -58,7 +58,7 @@ spec:
58
58
 
59
59
  # Storage configuration
60
60
  - name: JIVA_STORAGE_PROVIDER
61
- value: "gcp"
61
+ value: "gcp-bucket"
62
62
  - name: JIVA_GCP_BUCKET
63
63
  value: "jiva-state-BUCKET_NAME"
64
64
  - name: JIVA_GCP_PROJECT
@@ -57,7 +57,7 @@ spec:
57
57
 
58
58
  # Storage configuration
59
59
  - name: JIVA_STORAGE_PROVIDER
60
- value: "gcp"
60
+ value: "gcp-bucket"
61
61
  - name: JIVA_GCP_BUCKET
62
62
  value: "jiva-state-BUCKET_NAME"
63
63
  - name: JIVA_GCP_PROJECT
@@ -35,24 +35,30 @@ export declare class ClientAgent {
35
35
  private mcpManager;
36
36
  private mcpClient;
37
37
  private failureCount;
38
- private readonly ALLOWED_TOOLS;
38
+ private _availableTools;
39
39
  constructor(orchestrator: ModelOrchestrator, mcpManager: MCPServerManager);
40
40
  /**
41
- * Use LLM to analyze the task and determine involvement level + requirements.
42
- * Replaces keyword-based determineInvolvementLevel() and parseRequirements()
43
- * with semantic understanding that avoids false positives.
41
+ * Returns all tool names currently available from connected MCP servers.
42
+ * Result is cached after the first call; call resetToolCache() if servers change.
44
43
  */
45
- private analyzeTaskRequirements;
44
+ private getAvailableTools;
45
+ /** Reset the tool cache (e.g. after MCP server reconnects). */
46
+ resetToolCache(): void;
47
+ /**
48
+ * Find the first available tool whose name contains any of the given substrings.
49
+ * Returns null if no match is found.
50
+ */
51
+ private findTool;
46
52
  /**
47
- * @deprecated Use analyzeTaskRequirements() instead. Kept for reference.
48
- * Determine involvement level based on user request complexity
53
+ * Build a human-readable summary of available tool categories for LLM prompts.
49
54
  */
50
- determineInvolvementLevel(userMessage: string, subtasks: string[]): InvolvementLevel;
55
+ private buildToolContextForPrompt;
51
56
  /**
52
- * @deprecated Use analyzeTaskRequirements() instead. Kept for reference.
53
- * Parse requirements from user message
57
+ * Use LLM to analyze the task and determine involvement level + requirements.
58
+ * Replaces keyword-based determineInvolvementLevel() and parseRequirements()
59
+ * with semantic understanding that avoids false positives.
54
60
  */
55
- parseRequirements(userMessage: string, subtasks: string[]): Requirement[];
61
+ private analyzeTaskRequirements;
56
62
  /**
57
63
  * Validate Worker's work at appropriate involvement level
58
64
  */
@@ -78,26 +84,27 @@ export declare class ClientAgent {
78
84
  */
79
85
  private validateOutcome;
80
86
  /**
81
- * Check if file exists using read tool
87
+ * Check whether a file exists, using whichever MCP tool is available.
88
+ * Tries filesystem read tools first, then falls back to shell.
82
89
  */
83
90
  private fileExists;
84
91
  /**
85
92
  * Use LLM to generate an actionable correction instruction from raw validation issues.
86
- * Instead of echoing "requires using playwright__ but Worker did not use these tools",
87
- * produces something like "Use the filesystem tools to list ~/Library/Caches and report sizes".
93
+ * Translates internal validation failures into concrete, tool-specific directions
94
+ * for the Worker, referencing only the tools actually available in the system.
88
95
  */
89
96
  private generateCorrectionInstruction;
90
97
  /**
91
- * Validate file contents for common issues
98
+ * Validate file contents for common issues, using whichever MCP tool is available.
92
99
  */
93
100
  private validateFileContents;
94
101
  /**
95
- * Validate HTML file in browser
96
- */
97
- private validateInBrowser;
98
- /**
99
- * Reset failure tracking (for new conversation/session)
102
+ * THOROUGH-level shell-based verification: runs lightweight, read-only shell
103
+ * commands to confirm work was actually done (file sizes, test output presence, etc.).
104
+ * Skips gracefully when no shell tool is available.
100
105
  */
106
+ private validateWithShell;
107
+ /** Reset failure tracking (call at the start of each new conversation/session). */
101
108
  resetFailureTracking(): void;
102
109
  }
103
110
  //# sourceMappingURL=client-agent.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"client-agent.d.ts","sourceRoot":"","sources":["../../src/core/client-agent.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAE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